namespace TuanHA_Combat_Routine
{
    using CommonBehaviors.Actions;
    using Styx;
    using Styx.Common;
    using Styx.CommonBot;
    using Styx.CommonBot.Inventory;
    using Styx.CommonBot.Routines;
    using Styx.Helpers;
    using Styx.Pathing;
    using Styx.TreeSharp;
    using Styx.WoWInternals;
    using Styx.WoWInternals.WoWObjects;
    using System;
    using System.Collections.Generic;
    using System.Diagnostics;
    using System.IO;
    using System.Linq;
    using System.Net;
    using System.Runtime.CompilerServices;
    using System.Runtime.InteropServices;
    using System.Security.Cryptography;
    using System.Text;
    using System.Text.RegularExpressions;
    using System.Windows.Forms;
    using System.Windows.Media;

    public class Classname : CombatRoutine
    {
        private static bool _aoEModeOn;
        private Composite _combatBehavior;
        private Composite _deathBehavior;
        private static string _hasTalent = "";
        private Composite _preCombatBuffBehavior;
        private Composite _restBehavior;
        private readonly HashSet<string> AttackSpells = new HashSet<string> { 
            "Avenger's Shield", "Avenging Wrath", "Crusader Strike", "Consecration", "Divine Storm", "Exorcism", "Hammer of Justice", "Fist of Justice", "Hammer of the Righteous", "Hammer of Wrath", "Holy Wrath", "Inquisition", "Judgment", "Reckoning", "Righteous Fury", "Templar's Verdict", 
            "Turn Evil"
         };
        private static WoWUnit BestBloodBoilRoilingBloodTarget;
        private static WoWUnit BestPestilenceTarget;
        private static int BloodRuneSlot;
        private static DateTime BloodTapLast;
        private static readonly Stopwatch BMStopWatch = new Stopwatch();
        private static DateTime BreakCCLast;
        private static readonly HashSet<int> BuffBurstHS = new HashSet<int> { 
            0x1a436, 0x3004, 0x1da7f, 0xc847, 0xbf78, 0x190a0, 0x1e82e, 0x1a1c8, 0x4c76, 0xbe5, 0x30b8, 0x7c8c, 0x19d51, 0x152aa, 0x1528d, 0xca01, 
            0xc9ea, 0x35b6, 0x1bd81, 0x1bd83, 0x1bcc2, 0x6b7, 0x1be1f
         };
        private static readonly HashSet<int> BuffEnrageHS = new HashSet<int> { 0x32f6, 0x4843, 0xd98e };
        private static readonly HashSet<int> BuffHealHS = new HashSet<int> { 
            0x306, 0x22e8, 0x83e3, 0xbd36, 0xef6f, 0x3ce, 0xca12, 0x8b, 0x12ead, 0x12eb1, 0xbd74, 0x1c1cf, 0x1e70a, 0x1c1e7, 0x1e4b1, 0x11, 
            0x81b6, 0x12b7d, 0x51bd
         };
        private static bool Burst = false;
        private static DateTime BurstLast;
        private static readonly HashSet<uint> CanControlUndead = new HashSet<uint>();
        private static DateTime CanControlUndeadLast;
        private static Color colorlog;
        private static readonly string CombatRoutineFolder = "TuanHADKSpecialEdition";
        private static bool CurrentTargetCheckDebuffCCBreakonDamage;
        private static double CurrentTargetCheckDist;
        private static bool CurrentTargetCheckFacing;
        private static bool CurrentTargetCheckInLineOfSpellSight;
        private static bool CurrentTargetCheckInvulnerable;
        private static bool CurrentTargetCheckInvulnerableMagic;
        private static bool CurrentTargetCheckInvulnerablePhysic;
        private static bool CurrentTargetCheckIsEnemy;
        private static WoWUnit CurrentTargetCheckLast;
        private static DateTime CurrentTargetCheckLastTime;
        private static TimeSpan CurrentTargetCheckTimeOut;
        private const string DB = "wc.db";
        private static DateTime DeathCoilHealPetLast;
        private static int DeathRuneSlot;
        private static readonly HashSet<int> DebuffCCBreakonDamageHS = new HashSet<int> { 
            0x82e, 0x19bcd, 0x63, 0x7bad, 0xd1b, 0x6f0, 0xa4d, 0x1c244, 0x1c186, 0x1ed93, 0x1edd7, 0x76, 0xef79, 0x6e70, 0xf119, 0xf154, 
            0x6e6f, 0x4e62, 0x1a72, 0x4c2f, 0x2053c, 0x18d6, 0x1966d, 0x4bba
         };
        private static readonly HashSet<int> DebuffCCDurationHS = new HashSet<int> { 
            0x7609, 0x15ea6, 0x160e1, 710, 0x1bc89, 0x1918b, 0x12bec, 0x1cb16, 0x82e, 0x19bcd, 0x1c428, 0x1e201, 0x1edf3, 0x1dd82, 0x108b9, 0x1cdff, 
            0x83fa, 0x1bb62, 0x1ef2, 0x1d260, 0x729, 0xae1c, 0xd602, 0x63, 0x25d, 0x1d06f, 0x7bad, 0x12ec1, 0x1696, 0x1cfab, 0x1fe38, 0x7608, 
            0x19c79, 0x1caaa, 0xd1b, 0x16698, 0x6f0, 0x355, 0x1b06a, 0xc93a, 0xa4d, 0x15a31, 0x1d120, 0x156c, 0x58af, 0x1b9a0, 0x1b96c, 0x147e, 
            0x501f, 0x5f4a, 0x198, 0x1d255, 0x1ed26, 0x582a, 0x1c244, 0x145b, 0x16695, 0x1a85, 0x1c186, 0x1bd21, 0x1ed93, 0x1edd7, 0x76, 0xef79, 
            0x6e70, 0xf119, 0xf154, 0x6e6f, 0x232d, 0x19092, 0xfa2c, 0x1fba, 0x1bc80, 0x1ce49, 0x1a247, 0x340f, 0x1c139, 0x4e62, 0x14303, 0x1a72, 
            0x5e9, 0x4c2f, 0x2053c, 0x18d6, 0x250c, 0x764b, 0x20448, 0x154a4, 0x1966d, 0xc557, 0x1d079, 0xdd32, 0x1a432, 0x2856, 0x259d3, 0x5045, 
            0x19d2b, 0x4bba, 0x1a6a2
         };
        private static readonly HashSet<int> DebuffCCHS = new HashSet<int> { 
            0x7609, 0x15ea6, 0x160e1, 710, 0x1bc89, 0x1918b, 0x12bec, 0x1cb16, 0x82e, 0x19bcd, 0x1c428, 0x1e201, 0x1edf3, 0x1dd82, 0x108b9, 0x1cdff, 
            0x83fa, 0x1bb62, 0x1ef2, 0x1d260, 0x729, 0xae1c, 0xd602, 0x63, 0x25d, 0x1d06f, 0x7bad, 0x12ec1, 0x1696, 0x1cfab, 0x1fe38, 0x7608, 
            0x19c79, 0x1caaa, 0xd1b, 0x16698, 0x6f0, 0x355, 0x1b06a, 0xc93a, 0xa4d, 0x15a31, 0x1d120, 0x156c, 0x58af, 0x1b9a0, 0x1b96c, 0x147e, 
            0x501f, 0x5f4a, 0x198, 0x1d255, 0x1ed26, 0x582a, 0x1c244, 0x145b, 0x16695, 0x1a85, 0x1c186, 0x1bd21, 0x1ed93, 0x1edd7, 0x76, 0xef79, 
            0x6e70, 0xf119, 0xf154, 0x6e6f, 0x232d, 0x19092, 0xfa2c, 0x1fba, 0x1bc80, 0x1ce49, 0x1a247, 0x340f, 0x1c139, 0x4e62, 0x14303, 0x1a72, 
            0x5e9, 0x4c2f, 0x2053c, 0x18d6, 0x250c, 0x764b, 0x20448, 0x154a4, 0x1966d, 0xc557, 0x1d079, 0xdd32, 0x1a432, 0x2856, 0x259d3, 0x5045, 
            0x19d2b, 0x4bba, 0x1a6a2
         };
        private static readonly HashSet<int> DebuffCCleanseASAPHSWarrior = new HashSet<int> { 0x1696, 0x1cfab, 0x1fe38, 0xfa2c, 0x1fba, 0x1bc80 };
        private static readonly HashSet<int> DebuffCCleanseASAPPvEHS = new HashSet<int> { 
            0x1cf18, 0x1d4b1, 0x1cabc, 0x1e7bf, 0x1e083, 0x1e084, 0x21604, 0x2160f, 0x2158b, 0x21606, 0x21540, 0x21699, 0x213f9, 0x213fb, 0x213f7, 0x213f5, 
            0x21b38, 0x1ccbd, 0x23736
         };
        private static readonly HashSet<int> DebuffCCleanseASAPPvPHS = new HashSet<int> { 
            0x19bcd, 0x1e201, 0xae1c, 0x25d, 0x7bad, 0x1696, 0x1cfab, 0x1fe38, 0xd1b, 0x355, 0x1b06a, 0xc93a, 0xa4d, 0x15a31, 0x1d120, 0x156c, 
            0x1c244, 0x1a85, 0x1bd21, 0x1ed93, 0x76, 0xef79, 0x6e70, 0xf119, 0xf154, 0x6e6f, 0xfa2c, 0x1fba, 0x1bc80, 0x1a247, 0x1c139, 0x4e62, 
            0x14303, 0x5e9, 0x2053c, 0x18d6, 0x250c, 0x764b, 0x154a4, 0x1966d, 0x1d079, 0x2856, 0x259d3, 0x4bba, 0x1b934
         };
        private static readonly HashSet<int> DebuffDisarmHS = new HashSet<int> { 0xc56d, 0x2a4, 0x1cd4d, 0xca0a, 0x1ca78, 0x1edfa, 0xfa3a, 0x165fc };
        private static readonly HashSet<int> DebuffDoNotCleanseHS = new HashSet<int> { 0x213f8, 0x213fa, 0x213f4, 0x213f6, 0x759c, 0x21d71, 0x21dec, 0x21ded, 0x8862 };
        private static readonly HashSet<int> DebuffDoNotHealHS = new HashSet<int> { 0x2187d, 0x21874, 0x25d, 0x83fa, 0x1e177, 0x1e130, 0x1dc5d, 0x21890, 0x1de02, 0x22e11 };
        private static readonly HashSet<int> DebuffFearDurationHS = new HashSet<int> { 0x1696, 0x1cfab, 0x1fe38, 0x156c, 0x1b9a0, 0x1b96c, 0x147e, 0x501f, 0x1c244, 0xfa2c, 0x1fba, 0x1bc80, 0x2053c, 0x18d6, 0x154a4, 0x1966d };
        private static readonly HashSet<int> DebuffMagicCCDurationHS = new HashSet<int> { 
            710, 0x12bec, 0x1cb16, 0x19bcd, 0x1c428, 0x1e201, 0x1cdff, 0xae1c, 0x63, 0x25d, 0x7bad, 0x1696, 0x1cfab, 0x1fe38, 0x19c79, 0x1caaa, 
            0xd1b, 0x355, 0x1b06a, 0xa4d, 0xc93a, 0x15a31, 0x1d120, 0x156c, 0x1ed26, 0x1c244, 0x1a85, 0x76, 0xef79, 0x6e70, 0xf119, 0xf154, 
            0x6e6f, 0xfa2c, 0x1fba, 0x1bc80, 0x1a247, 0x1c139, 0x4e62, 0x14303, 0x5e9, 0x4c2f, 0x2053c, 0x18d6, 0x250c, 0x764b, 0x154a4, 0x1966d, 
            0xc557, 0x1d079, 0x2856, 0x259d3, 0x1a6a2
         };
        private static readonly HashSet<int> DebuffRootCanCleanseHS = new HashSet<int> { 
            0x17826, 0xfcb7, 0x153, 0x1bc6a, 0x4e07, 0x1ba7b, 0x1ba7b, 0x4af1, 0x8273, 0xf8c5, 0x7a, 0x1b065, 0x1549a, 0x1b2ec, 0x18fd7, 0x215ba, 
            0x1c1fd, 0x1669f, 0x1e20f, 0xd5b2, 0x1047
         };
        private static readonly HashSet<int> DebuffRootCanCloakHS = new HashSet<int> { 
            0x17826, 0xfcb7, 0x153, 0x1bc6a, 0x4e07, 0x1ba7b, 0x1ba7b, 0x4af1, 0x8273, 0xf8c5, 0x7a, 0x1b065, 0x1549a, 0x1b2ec, 0x18fd7, 0x1e20f, 
            0xd5b2, 0x1bee4, 0x1047
         };
        private static readonly HashSet<int> DebuffRootHS = new HashSet<int> { 
            0x17826, 0x1c7e2, 0xfcb7, 0x153, 0x1bc6a, 0x4e07, 0x1ba7b, 0x1ba7b, 0x4af1, 0x8273, 0xf8c5, 0x9c1d, 0x7a, 0x1b065, 0xd8f0, 0x1549a, 
            0x1b2ec, 0xb116, 0x160d7, 0x18fd7, 0x215ba, 0x332b, 0x1c1fd, 0xc445, 0x1669f, 0x1e20f, 0x1a42e, 0xd5b2, 0x1bee4, 0x1047
         };
        private static readonly HashSet<int> DebuffRootorSnareHS = new HashSet<int> { 
            0x17826, 0x1c7e2, 0xfcb7, 0x153, 0x1bc6a, 0x4e07, 0x1ba7b, 0x1ba7b, 0x4af1, 0x8273, 0xf8c5, 0x9c1d, 0x7a, 0x1b065, 0xd8f0, 0x1549a, 
            0x1b2ec, 0xb116, 0x160d7, 0x18fd7, 0x215ba, 0x332b, 0x1c1fd, 0xc445, 0x1669f, 0x1e20f, 0x1a42e, 0xd5b2, 0x1bee4, 0x1047, 0xc501, 0x1aedc, 
            0x891d, 0x13fc, 120, 0xd51, 0x472f, 0xb1d4, 0xc503, 0x1d9c8, 0x644, 0xf829, 0xc453, 0x6837, 0x1d390, 0x1c57f, 0x1e34f, 0xe10, 
            0x12ea6, 0x1e2c2, 0x1b9c4, 0xd574, 0x1f78, 0x74, 0x1f62, 0xae46, 0xefd2, 0x6b3, 0x35f2, 0xe344, 0x1cf39, 0x3c2f, 0x3023, 0x1c138, 
            0x4eca, 0xbb58, 0x7b65, 0x1fb83, 0xefcf, 0xc922, 0x1f335, 0x219a5
         };
        private static readonly HashSet<int> DebuffSilenceHS = new HashSet<int> { 
            0x1fa3d, 0x61d6, 0x13a63, 0x703a, 0x10e3b, 0xc5b5, 0x7cbf, 0x1be3e, 0x18ea3, 0x532, 0x1c446, 0x3c7f, 0x4842, 0xd6ed, 0x86ba, 0x13d6d, 
            0x1ba87, 0x1c7e5, 0x5ec3, 0x20539, 0xb974, 0x798d
         };
        private static readonly HashSet<int> DebuffSnareHS = new HashSet<int> { 
            0xc501, 0x1aedc, 0x891d, 0x13fc, 120, 0xd51, 0x472f, 0xb1d4, 0xc503, 0x1d9c8, 0x644, 0xf829, 0xc453, 0x6837, 0x1d390, 0x1c57f, 
            0x1e34f, 0xe10, 0x12ea6, 0x1e2c2, 0x1b9c4, 0xd574, 0x1f78, 0x74, 0x1f62, 0xae46, 0xefd2, 0x6b3, 0x35f2, 0xe344, 0x1cf39, 0x3c2f, 
            0x3023, 0x1c138, 0x4eca, 0xbb58, 0x7b65, 0x1fb83, 0xefcf, 0xc922, 0x1f335, 0x219a5, 0x11fd2
         };
        private static readonly HashSet<int> DebuffStunDurationHS = new HashSet<int> { 
            0x15ea6, 0x1bc89, 0x1918b, 0x1cb16, 0x1edf3, 0x1dd82, 0x1d260, 0x729, 0xae1c, 0xd602, 0x19c79, 0x1caaa, 0x16698, 0x355, 0x1b06a, 0x5f4a, 
            0x198, 0x1d255, 0x145b, 0x16695, 0x232d, 0x19092, 0x1c139, 0x14303, 0x764b, 0x20448, 0x1d079, 0x5045, 0x1a6a2, 0x1bd21
         };
        private static readonly HashSet<int> DebuffStunFearDurationHS = new HashSet<int> { 
            0x1d260, 0x729, 0xae1c, 0x7bad, 0x12ec1, 0x1696, 0x1cfab, 0x1fe38, 0x19c79, 0x1caaa, 0x355, 0x1b06a, 0x1b9a0, 0x1b96c, 0x147e, 0x501f, 
            0x5f4a, 0x198, 0x1d255, 0x145b, 0x16695, 0x232d, 0x19092, 0xfa2c, 0x1fba, 0x1bc80, 0x1ce49, 0x1c139, 0x14303, 0x764b, 0x20448, 0x154a4, 
            0x19d2b, 0x1a6a2
         };
        private readonly HashSet<string> DefendSpells = new HashSet<string> { "[Ardent Defender", "Cleanse", "Devotion Aura", "Divine Protection", "Divine Shield", "Emancipate", "Flash of Light", "Hand of Freedom", "Hand of Protection", "Hand of Sacrifice", "Hand of Salvation", "Holy Radiance", "Lay on Hands", "Redemption", "Sacred Shield" };
        private static readonly HashSet<int> DoNotInterrupt = new HashSet<int> { 0xe40, 0x12fc7, 0xdd41, 0x193, 0x1bbf8, 0x5045, 0x1c25e, 0x1aacb };
        private static readonly Dictionary<ulong, DateTime> EnemyListCache = new Dictionary<ulong, DateTime>();
        private static DateTime EnemyListCacheClearLast;
        private static DateTime FacingDelay;
        internal static int FailLoginAttempt;
        internal static DateTime FailLoginNextTime;
        private static readonly List<WoWUnit> FarFriendlyPlayers = new List<WoWUnit>();
        private static readonly List<WoWUnit> FarFriendlyUnits = new List<WoWUnit>();
        private static readonly List<WoWUnit> FarUnFriendlyPlayers = new List<WoWUnit>();
        private static readonly List<WoWUnit> FarUnFriendlyUnits = new List<WoWUnit>();
        private static readonly Dictionary<ulong, DateTime> FriendListCache = new Dictionary<ulong, DateTime>();
        private static DateTime FriendListCacheClearLast;
        private static int FrostRuneSlot;
        private static DateTime GetUnitRaiseAllyLastSearch;
        private static DateTime GlobalCheckTime;
        private static int GlyphprivateofPestilenceBonus = 0;
        private static string HasGlyph;
        private static string HasGlyphName;
        private static DateTime HoldPetAction;
        private static readonly HashSet<WoWApplyAuraType> HS_HasAuraTypeDOT = new HashSet<WoWApplyAuraType> { 3, 0x59 };
        private static readonly HashSet<int> HS_NOTDOT = new HashSet<int> { 
            0x14b0b, 0x14b0a, 0x14b09, 0x173f7, 0x116a0, 0xb07d, 0x1d33b, 0x1ce0b, 0xd193, 0xe24e, 0x187f4, 0xe17b, 0xe17c, 0x139e2, 0x64ab, 0x177df, 
            0x17641, 0x2bbc, 0x1f3e5
         };
        private const string initVector = "www.tuanha.biz/l";
        private static readonly Dictionary<ulong, DateTime> InLineOfSpellSightCache = new Dictionary<ulong, DateTime>();
        private static readonly HashSet<int> InvulnerableHS = new HashSet<int> { 0x83fa, 0x4b3f, 0xb9e1, 0x282, 0xb17e, 0x6cb3 };
        private static readonly HashSet<int> InvulnerableRootandSnareHS = new HashSet<int> { 0xd017, 0xb74c, 0x414 };
        private static readonly HashSet<int> InvulnerableSpellHS = new HashSet<int> { 0xbe43, 0x79f8, 0x1c40b, 0x1ff2, 0x1bd6c, 0x5d70, 0x201c3 };
        private static readonly HashSet<int> InvulnerableStunHS = new HashSet<int> { 0xbe98, 0xb74c };
        private static bool IsOverrideModeOn;
        private static bool IsUsingAFKBot;
        private static TimeSpan ItemCooldownBack;
        private static readonly Dictionary<WoWItem, DateTime> ItemsCooldownCache = new Dictionary<WoWItem, DateTime>();
        private const int keysize = 0x100;
        public Keys KeyTwo;
        private static DateTime LastAutoTarget;
        private static DateTime LastCap;
        private static DateTime LastCastontheGround;
        private static WoWPoint LastCastontheGroundPosition;
        private static string LastCastSpell;
        private static DateTime LastCastTime;
        private static WoWUnit LastCastUnit;
        private static DateTime LastChainsofIce;
        private static DateTime LastChainsofIceMelee;
        private static DateTime LastControlUndead;
        private static DateTime LastFrostFeverDebuff;
        private static DateTime LastGripSnare;
        private static DateTime LastInterrupt = DateTime.Now;
        private static DateTime LastPathofFrost = DateTime.Now;
        private static DateTime LastPlagueLeech;
        private static DateTime LastProc;
        private static DateTime LastRotationTime;
        private static DateTime LastShield;
        private static DateTime LastSpreadDiseases;
        private static DateTime LastSwitch;
        private static DateTime LastTaunt;
        private static DateTime LastWriteDebug;
        private static DateTime LastWriteLog;
        private static readonly string LocalFolder = Path.Combine(Utilities.AssemblyDirectory, @"Routines\" + CombatRoutineFolder);
        internal static bool LoginCheckVal = false;
        private static double MeMaxHealth;
        internal const string Msp = "d";
        private static WoWUnit MyLastTarget;
        private static double MyLatency;
        private static readonly List<WoWUnit> NearbyFriendlyPlayers = new List<WoWUnit>();
        private static readonly List<WoWUnit> NearbyFriendlyUnits = new List<WoWUnit>();
        private static readonly List<WoWUnit> NearbyUnFriendlyPlayers = new List<WoWUnit>();
        private static readonly List<WoWUnit> NearbyUnFriendlyUnits = new List<WoWUnit>();
        private static readonly Stopwatch NecroticStrikeSW = Stopwatch.StartNew();
        private static readonly HashSet<uint> NeedHealUnitHS = new HashSet<uint> { 0xf3ea, 0x116ec, 0x115fe, 0x115fd, 0x116bd, 0x11a1a, 0x11a1b, 0x11a1d, 0x11a1c, 0x11894, 0x117b4, 0x117b4, 0x1193b, 0x1193c, 0x11738 };
        private static bool NeedResetPresence;
        private static DateTime NextSuppressMessage = DateTime.MinValue;
        private static readonly HashSet<string> NoGCDSpells = new HashSet<string>();
        private const string PATTERN = "/!svn/ver/(?'version'[0-9]*)/";
        private static readonly List<WoWPetSpell> PetSpells = new List<WoWPetSpell>();
        private static DateTime PresenceSwapLast = DateTime.Now;
        internal static string RealName;
        private const int RezMaxMobsNear = 0;
        private const int RezWaitDist = 20;
        private const int RezWaitTime = 10;
        internal static string SafeCharName;
        private static readonly HashSet<int> SafeUsingCooldownHS = new HashSet<int> { 0x149d, 0xb74c };
        private static DateTime SearchFlagTime;
        private static DateTime SetAutoAttackLast;
        private readonly HashSet<string> SpecialSpells = new HashSet<string> { "Guardian of Ancient Kings", "Holy Avenger", "Holy Prism", "Rebuke" };
        private static DateTime spellCooldownBack;
        private static readonly Dictionary<string, DateTime> SpellsCooldownCache = new Dictionary<string, DateTime>();
        private static readonly HashSet<string> SpellsCooldownHS = new HashSet<string> { 
            "Arcane Torrent", "Berserking", "Blood Fury", "Cannibalize", "Darkflight", "Escape Artist", "Every Man for Himself", "Gift of the Naaru", "Rocket Jump", "Shadowmeld", "Stoneform", "War Stomp", "Will of the Forsaken", "Avenging Wrath", "Ardent Defender", "Blinding Light", 
            "Beacon of Light", "Consecration", "Crusader Strike", "Devotion Aura", "Divine Favor ", "Divine Plea", "Divine Protection", "Divine Shield", "Execution Sentence", "Fist of Justice", "Guardian of Ancient Kings", "Hammer of Justice", "Hammer of the Righteous", "Hand of Freedom", "Hand of Protection", "Hand of Purity", 
            "Hand of Sacrifice", "Hand of Salvation", "Holy Avenger", "Holy Prism", "Holy Shock", "Judgment", "Lay on Hands", "Light's Hammer", "Rebuke", "Reckoning", "Repentance", "Sacred Shield", "Speed of Light", "Turn Evil"
         };
        private const string SVNURL = "https://tuanha.sourcerepo.com/tuanha/tuanhadkspecialedition.5.4/";
        private static int UnholyRuneSlot;
        private static WoWUnit UnitArcaneTorrent;
        private static WoWUnit UnitAsphyxiateHelpFriend;
        private static WoWUnit UnitAttackASAP;
        private static WoWUnit UnitAttackingMyPet;
        private static WoWUnit UnitBestTarget;
        private static WoWUnit UnitChainsofIceMelee;
        private static WoWUnit UnitControlUndead;
        private static WoWUnit UnitControlUndeadLast;
        private static WoWUnit UnitDarkCommand;
        private static WoWUnit UnitDarkSimulacrum;
        private static WoWUnit UnitDeathGripFarUnit;
        private static WoWUnit UnitDeathGripMelee;
        private static WoWUnit UnitDeathGripRemorselessWinter;
        private static WoWUnit UnitDeathGripTaunt;
        private static WoWUnit UnitDeathStrikeBloodPvP;
        private static WoWUnit UnitGorefiendsGraspAggro;
        private static WoWUnit UnitGorefiendsGraspAoE;
        private static WoWUnit UnitGorefiendsGraspMelee;
        private static WoWUnit UnitInterrupt;
        private static WoWUnit UnitPetStunEnemyLowHP;
        private static WoWUnit UnitPetStunSaveFriendLowHP;
        private static WoWPlayer UnitRaiseAlly;
        private static WoWUnit UnitStrangulateLow;
        internal static int UseSpecialization;
        internal static string VersionBuild = "";

        private static Composite AntiMagicShell()
        {
            return (Composite) new Decorator(ret => (((THSettings.Instance.AntiMagicShell && ((LastShield + TimeSpan.FromMilliseconds(3000.0)) < DateTime.Now)) && (Me.Combat && CurrentTargetAttackable(30.0, false, false))) && (!MeHasAura("Anti-Magic Zone") && (Me.HealthPercent <= THSettings.Instance.AntiMagicShellHP))) && CanCastCheck("Anti-Magic Shell", true), (Composite) new Styx.TreeSharp.Action(delegate (object ret) {
                LastShield = DateTime.Now;
                CastSpell("Anti-Magic Shell", (WoWUnit) Me, "AntiMagicShellHP");
                return (RunStatus) RunStatus.Failure;
            }));
        }

        private static Composite AntiMagicShellCaster()
        {
            return (Composite) new Decorator(ret => (((THSettings.Instance.AntiMagicShellCaster && ((LastShield + TimeSpan.FromMilliseconds(3000.0)) < DateTime.Now)) && (Me.Combat && !MeHasAura("Anti-Magic Zone"))) && CanCastCheck("Anti-Magic Shell", true)) && (CountMagicDPSTarget((WoWUnit) Me) >= THSettings.Instance.AntiMagicShellCasterNumber), (Composite) new Styx.TreeSharp.Action(delegate (object ret) {
                LastShield = DateTime.Now;
                CastSpell("Anti-Magic Shell", (WoWUnit) Me, "AntiMagicShellCaster");
                return (RunStatus) RunStatus.Failure;
            }));
        }

        private static Composite AntiMagicShellDebuff()
        {
            return (Composite) new Decorator(delegate (object ret) {
                if (((!THSettings.Instance.AntiMagicShellDebuff || ((LastShield + TimeSpan.FromMilliseconds(3000.0)) >= DateTime.Now)) || (!Me.Combat || MeHasAura("Anti-Magic Zone"))) || ((CountDebuffMagic((WoWUnit) Me) < THSettings.Instance.AntiMagicShellDebuffNumber) && (!MeHasAura(0x1c138) || (Me.GetAuraById(0x1c138).StackCount < 2))))
                {
                    return false;
                }
                return CanCastCheck("Anti-Magic Shell", true);
            }, (Composite) new Styx.TreeSharp.Action(delegate (object ret) {
                LastShield = DateTime.Now;
                CastSpell("Anti-Magic Shell", (WoWUnit) Me, "AntiMagicShellDebuff");
                return (RunStatus) RunStatus.Failure;
            }));
        }

        private static Composite AntiMagicShellEnemy()
        {
            return (Composite) new Decorator(ret => (((THSettings.Instance.AntiMagicShellEnemy && ((LastShield + TimeSpan.FromMilliseconds(3000.0)) < DateTime.Now)) && (Me.Combat && CurrentTargetAttackable(10.0, false, false))) && ((Me.get_CurrentTarget().get_PowerType() == ((WoWPowerType) ((int) WoWPowerType.Mana))) && (Me.get_CurrentTarget().HealthPercent <= THSettings.Instance.AntiMagicShellEnemyHP))) && CanCastCheck("Anti-Magic Shell", true), (Composite) new Styx.TreeSharp.Action(delegate (object ret) {
                LastShield = DateTime.Now;
                CastSpell("Anti-Magic Shell", (WoWUnit) Me, "AntiMagicShellEnemyHP");
                return (RunStatus) RunStatus.Failure;
            }));
        }

        private static Composite AntiMagicShellLichborne()
        {
            return (Composite) new Decorator(ret => ((((THSettings.Instance.AntiMagicShellLichborne && ((LastShield + TimeSpan.FromMilliseconds(3000.0)) < DateTime.Now)) && (Me.Combat && MeHasAura("Lichborne"))) && (Me.get_CurrentMap().IsArena || Me.get_CurrentMap().IsBattleground)) && CanCastCheck("Anti-Magic Shell", true)) && HasPaladinPriestAround(), (Composite) new Styx.TreeSharp.Action(delegate (object ret) {
                LastShield = DateTime.Now;
                CastSpell("Anti-Magic Shell", (WoWUnit) Me, "AntiMagicShellLichborne");
                return (RunStatus) RunStatus.Failure;
            }));
        }

        private static Composite AntiMagicZone()
        {
            return (Composite) new Decorator(ret => (((THSettings.Instance.AntiMagicZone && ((LastShield + TimeSpan.FromMilliseconds(3000.0)) < DateTime.Now)) && (!IsMoving((WoWUnit) Me) && Me.Combat)) && ((CurrentTargetAttackable(30.0, false, false) && !MeHasAura("Anti-Magic Shell")) && (Me.HealthPercent <= THSettings.Instance.AntiMagicZoneHP))) && CanCastCheck("Anti-Magic Zone", true), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                LastShield = DateTime.Now;
                LastCastontheGround = DateTime.Now;
                CastSpell("Anti-Magic Zone", (WoWUnit) Me, "AntiMagicZone");
                new Wait(TimeSpan.FromMilliseconds(1000.0), ret => Me.get_CurrentPendingCursorSpell() != null, (Composite) new ActionAlwaysSucceed());
                LastCastontheGroundPosition = CalculateDropLocation((WoWUnit) Me);
                SpellManager.ClickRemoteLocation(LastCastontheGroundPosition);
                return (RunStatus) RunStatus.Failure;
            }));
        }

        private static Composite AntiMagicZoneCaster()
        {
            return (Composite) new Decorator(ret => (((THSettings.Instance.AntiMagicShellCaster && ((LastShield + TimeSpan.FromMilliseconds(3000.0)) < DateTime.Now)) && (!IsMoving((WoWUnit) Me) && Me.Combat)) && (!MeHasAura("Anti-Magic Shell") && CanCastCheck("Anti-Magic Zone", true))) && (CountMagicDPSTarget((WoWUnit) Me) >= THSettings.Instance.AntiMagicShellCasterNumber), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                LastShield = DateTime.Now;
                LastCastontheGround = DateTime.Now;
                CastSpell("Anti-Magic Zone", (WoWUnit) Me, "AntiMagicZoneCaster");
                new Wait(TimeSpan.FromMilliseconds(1000.0), ret => Me.get_CurrentPendingCursorSpell() != null, (Composite) new ActionAlwaysSucceed());
                LastCastontheGroundPosition = CalculateDropLocation((WoWUnit) Me);
                SpellManager.ClickRemoteLocation(LastCastontheGroundPosition);
                return (RunStatus) RunStatus.Failure;
            }));
        }

        private static Composite AntiMagicZoneDebuff()
        {
            return (Composite) new Decorator(ret => (((THSettings.Instance.AntiMagicZoneDebuff && ((LastShield + TimeSpan.FromMilliseconds(3000.0)) < DateTime.Now)) && (!IsMoving((WoWUnit) Me) && Me.Combat)) && (!MeHasAura("Anti-Magic Shell") && (CountDebuffMagic((WoWUnit) Me) >= THSettings.Instance.AntiMagicZoneDebuffNumber))) && CanCastCheck("Anti-Magic Zone", true), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                LastShield = DateTime.Now;
                LastCastontheGround = DateTime.Now;
                CastSpell("Anti-Magic Zone", (WoWUnit) Me, "AntiMagicZoneDebuff");
                new Wait(TimeSpan.FromMilliseconds(1000.0), ret => Me.get_CurrentPendingCursorSpell() != null, (Composite) new ActionAlwaysSucceed());
                LastCastontheGroundPosition = CalculateDropLocation((WoWUnit) Me);
                SpellManager.ClickRemoteLocation(LastCastontheGroundPosition);
                return (RunStatus) RunStatus.Failure;
            }));
        }

        private static void ArcaneTorrentVoid()
        {
            if ((THSettings.Instance.AutoRacial && (LastInterrupt < DateTime.Now)) && (CanCastCheck("Arcane Torrent", true) && GetUnitArcaneTorrent()))
            {
                if (Me.IsCasting)
                {
                    SpellManager.StopCasting();
                }
                if ((UnitArcaneTorrent.IsCasting && (UnitArcaneTorrent.CurrentCastTimeLeft.TotalMilliseconds > (MyLatency + 50.0))) || UnitArcaneTorrent.IsChanneling)
                {
                    CastSpell("Arcane Torrent", (WoWUnit) Me, "Arcane Torrent");
                    LastInterrupt = DateTime.Now + TimeSpan.FromMilliseconds(1500.0);
                }
            }
        }

        private static void AsphyxiateVoid()
        {
            if (((THSettings.Instance.StrangulateInterrupt && ((LastInterrupt + TimeSpan.FromMilliseconds(1000.0)) < DateTime.Now)) && (Me.Combat && CanCastCheck("Asphyxiate", true))) && GetUnitAsphyxiateInterrupt())
            {
                if (Me.IsCasting)
                {
                    SpellManager.StopCasting();
                }
                FacingDelay = DateTime.Now;
                if ((THSettings.Instance.AutoFace && ((FacingDelay + TimeSpan.FromMilliseconds(100.0)) > DateTime.Now)) && !Me.IsFacing((WoWObject) UnitInterrupt))
                {
                    Me.SetFacing(UnitInterrupt);
                }
                if ((UnitInterrupt.IsCasting && (UnitInterrupt.CurrentCastTimeLeft.TotalMilliseconds > (MyLatency + 50.0))) || UnitInterrupt.IsChanneling)
                {
                    CastSpell("Asphyxiate", UnitInterrupt, "AsphyxiateVoid");
                    LastInterrupt = DateTime.Now;
                }
            }
        }

        private static bool Attackable(WoWUnit target, int range)
        {
            return (((BasicCheck(target) && !Blacklist.Contains(target.Guid, ((BlacklistFlags) BlacklistFlags.Pull) | (((BlacklistFlags) BlacklistFlags.Interact) | (((BlacklistFlags) BlacklistFlags.Node) | (((BlacklistFlags) BlacklistFlags.Combat) | ((BlacklistFlags) BlacklistFlags.Loot)))))) && ((GetDistance(target) <= range) && !Invulnerable(target))) && ((!DebuffCCBreakonDamage(target) && IsEnemy(target)) && (((range <= 5) || (GetDistance(target) <= 5f)) || InLineOfSpellSightCheck(target))));
        }

        private static bool AttackableNoCC(WoWUnit target, int range)
        {
            return (((BasicCheck(target) && !Blacklist.Contains(target.Guid, ((BlacklistFlags) BlacklistFlags.Pull) | (((BlacklistFlags) BlacklistFlags.Interact) | (((BlacklistFlags) BlacklistFlags.Node) | (((BlacklistFlags) BlacklistFlags.Combat) | ((BlacklistFlags) BlacklistFlags.Loot)))))) && ((GetDistance(target) <= range) && !Invulnerable(target))) && (IsEnemy(target) && (((range <= 5) || (GetDistance(target) <= 5f)) || InLineOfSpellSightCheck(target))));
        }

        private static bool AttackableNoCCLoS(WoWUnit target, int range)
        {
            return ((BasicCheck(target) && !Blacklist.Contains(target.Guid, ((BlacklistFlags) BlacklistFlags.Pull) | (((BlacklistFlags) BlacklistFlags.Interact) | (((BlacklistFlags) BlacklistFlags.Node) | (((BlacklistFlags) BlacklistFlags.Combat) | ((BlacklistFlags) BlacklistFlags.Loot)))))) && (((GetDistance(target) <= range) && !Invulnerable(target)) && IsEnemy(target)));
        }

        private static bool AttackableNoLoS(WoWUnit target, int range)
        {
            return (((BasicCheck(target) && !Blacklist.Contains(target.Guid, ((BlacklistFlags) BlacklistFlags.Pull) | (((BlacklistFlags) BlacklistFlags.Interact) | (((BlacklistFlags) BlacklistFlags.Node) | (((BlacklistFlags) BlacklistFlags.Combat) | ((BlacklistFlags) BlacklistFlags.Loot)))))) && ((GetDistance(target) <= range) && !Invulnerable(target))) && (!DebuffCCBreakonDamage(target) && IsEnemy(target)));
        }

        private static Composite AttackASAP()
        {
            Composite[] compositeArray = new Composite[] { (Composite) new Decorator(ret => (((THSettings.Instance.AttackASAP && ((HoldPetAction + TimeSpan.FromMilliseconds(4000.0)) < DateTime.Now)) && (Me.GotAlivePet && !DebuffCC(Me.get_Pet()))) && !DebuffRoot(Me.get_Pet())) && GetUnitAttackASAP(), (Composite) new Styx.TreeSharp.Action(delegate (object ret) {
                if (PetCanCastAction("Leap"))
                {
                    PetCastAction("Leap", UnitAttackASAP);
                }
                PetCastAction("Attack", UnitAttackASAP);
                HoldPetAction = DateTime.Now;
                return (RunStatus) RunStatus.Failure;
            })), (Composite) new Decorator(ret => (THSettings.Instance.AttackASAP && CanCastCheck("Icy Touch", false)) && GetUnitAttackASAP(), (Composite) new Styx.TreeSharp.Action(delegate (object ret) {
                SafelyFacingTarget(UnitAttackASAP);
                CastSpell("Icy Touch", UnitAttackASAP, "Icy Touch: Flag Capper or Totem");
            })), (Composite) new Decorator(ret => (THSettings.Instance.AttackASAP && CanCastCheck("Death Coil", false)) && GetUnitAttackASAP(), (Composite) new Styx.TreeSharp.Action(delegate (object ret) {
                SafelyFacingTarget(UnitAttackASAP);
                CastSpell("Death Coil", UnitAttackASAP, "Death Coil: Flag Capper or Totem");
            })) };
            return (Composite) new PrioritySelector(compositeArray);
        }

        private static Composite AutoTarget()
        {
            return (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                if (THSettings.Instance.AutoTarget && (LastAutoTarget <= DateTime.Now))
                {
                    if ((BasicCheck(Me.get_CurrentTarget()) && !CurrentTargetAttackableNoLoS(50.0)) && (GetBestTarget() && (Me.get_CurrentTarget() != UnitBestTarget)))
                    {
                        UnitBestTarget.Target();
                        Styx.Common.Logging.Write((Styx.Common.LogLevel) Styx.Common.LogLevel.Diagnostic, "Switch to Best Unit");
                        LastAutoTarget = DateTime.Now + TimeSpan.FromMilliseconds(1000.0);
                        return (RunStatus) RunStatus.Failure;
                    }
                    if (!BasicCheck(Me.get_CurrentTarget()) && GetBestTarget())
                    {
                        UnitBestTarget.Target();
                        Styx.Common.Logging.Write((Styx.Common.LogLevel) Styx.Common.LogLevel.Diagnostic, "Target  Best Unit");
                        LastAutoTarget = DateTime.Now + TimeSpan.FromMilliseconds(1000.0);
                        return (RunStatus) RunStatus.Failure;
                    }
                    LastAutoTarget = DateTime.Now + TimeSpan.FromMilliseconds(1000.0);
                }
                return (RunStatus) RunStatus.Failure;
            });
        }

        private static Composite AutoTargetProt()
        {
            return (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                if (THSettings.Instance.AutoTarget && (LastAutoTarget <= DateTime.Now))
                {
                    if (Me.get_CurrentMap().IsArena || Me.get_CurrentMap().IsBattleground)
                    {
                        if ((BasicCheck(Me.get_CurrentTarget()) && !CurrentTargetAttackableNoLoS(50.0)) && (GetBestTarget() && (Me.get_CurrentTarget() != UnitBestTarget)))
                        {
                            UnitBestTarget.Target();
                            Styx.Common.Logging.Write((Styx.Common.LogLevel) Styx.Common.LogLevel.Diagnostic, "Switch to Best Unit");
                            LastAutoTarget = DateTime.Now + TimeSpan.FromMilliseconds(1000.0);
                            return (RunStatus) RunStatus.Failure;
                        }
                        if (!BasicCheck(Me.get_CurrentTarget()) && GetBestTarget())
                        {
                            UnitBestTarget.Target();
                            Styx.Common.Logging.Write((Styx.Common.LogLevel) Styx.Common.LogLevel.Diagnostic, "Target  Best Unit");
                            LastAutoTarget = DateTime.Now + TimeSpan.FromMilliseconds(1000.0);
                            return (RunStatus) RunStatus.Failure;
                        }
                    }
                    else if (GetBestTargetProt() && (Me.get_CurrentTarget() != UnitBestTarget))
                    {
                        UnitBestTarget.Target();
                        Styx.Common.Logging.Write((Styx.Common.LogLevel) Styx.Common.LogLevel.Diagnostic, "Switch to Best Unit Prot");
                        LastAutoTarget = DateTime.Now + TimeSpan.FromMilliseconds(1000.0);
                        return (RunStatus) RunStatus.Failure;
                    }
                    LastAutoTarget = DateTime.Now + TimeSpan.FromMilliseconds(1000.0);
                }
                return (RunStatus) RunStatus.Failure;
            });
        }

        private static bool BasicCheck(WoWUnit target)
        {
            return (((target != null) && target.IsValid) && target.IsAlive);
        }

        private void Benchmark(string functioName)
        {
            Styx.Common.Logging.Write(Me.SafeName);
            BMStopWatch.Reset();
            BMStopWatch.Start();
            BMStopWatch.Stop();
            Styx.Common.Logging.Write("{0} take {1} ms", new object[] { functioName, BMStopWatch.ElapsedMilliseconds });
            SpellManager.CanCast("lol");
            SpellManager.CanCast("Plague Strike", true);
        }

        private static Composite BloodBoil4Unit()
        {
            return (Composite) new Decorator(ret => (THSettings.Instance.BloodBoil && CanCastCheck("Blood Boil", false)) && (CountEnemyNear((WoWUnit) Me, 15f) >= 4.0), (Composite) new Styx.TreeSharp.Action(delegate (object ret) {
                CastSpell("Blood Boil", (WoWUnit) Me, "BloodBoil4Unit");
            }));
        }

        private static Composite BloodBoilProc()
        {
            return (Composite) new Decorator(ret => (((THSettings.Instance.BloodBoil && ((LastProc + TimeSpan.FromMilliseconds(2000.0)) < DateTime.Now)) && (MeHasAura(0x13cf5) && CurrentTargetAttackable(10.0, false, false))) && (MyAura("Frost Fever", Me.get_CurrentTarget()) && MyAura("Blood Plague", Me.get_CurrentTarget()))) && CanCastCheck("Blood Boil", false), (Composite) new Styx.TreeSharp.Action(delegate (object ret) {
                LastProc = DateTime.Now;
                CastSpell("Blood Boil", (WoWUnit) Me, "BloodBoilProc");
            }));
        }

        private static Composite BloodBoilRefreshDebuffAoE()
        {
            return (Composite) new Decorator(ret => (((THSettings.Instance.BloodBoil && SpellManager.HasSpell("Scarlet Fever")) && (CurrentTargetAttackable(10.0, false, false) && CanCastCheck("Blood Boil", false))) && ((HasEnemyDontHaveBloodPlague() && HasEnemyHaveBloodPlague()) && (HasEnemyDontHaveFrostFever() && HasEnemyHaveFrostFever()))) && !HasEnemyNearGotCCBreakonDamge(Me.get_CurrentTarget(), (float) (10 + GlyphprivateofPestilenceBonus)), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Blood Boil", (WoWUnit) Me, "BloodBoilRefreshDebuffAoE");
                LastSpreadDiseases = DateTime.Now + TimeSpan.FromMilliseconds(2000.0);
            }));
        }

        private static Composite BloodBoilRoilingBlood()
        {
            return (Composite) new Decorator(ret => (((THSettings.Instance.BloodBoil && (LastSpreadDiseases < DateTime.Now)) && (CanUseDeathRune() || (Me.BloodRuneCount > 0))) && ((SpellManager.HasSpell("Roiling Blood") && CanCastCheck("Blood Boil", false)) && (HasEnemyDontHaveBloodPlagueorFrostFever() && !HasEnemyNearGotCCBreakonDamge(Me.get_CurrentTarget(), (float) (10 + GlyphprivateofPestilenceBonus))))) && GetBestBloodBoilRoilingBloodTarget(), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Blood Boil", BestBloodBoilRoilingBloodTarget, "BloodBoilRoilingBlood");
                LastSpreadDiseases = DateTime.Now + TimeSpan.FromMilliseconds(2000.0);
            }));
        }

        private static Composite BloodBoilRoilingBloodConversion()
        {
            return (Composite) new Decorator(ret => ((((THSettings.Instance.BloodBoil && THSettings.Instance.NecroticStrikeStack) && ((LastSpreadDiseases < DateTime.Now) && CurrentTargetAttackable(10.0, false, false))) && ((SpellManager.HasSpell("Roiling Blood") && THSettings.Instance.NecroticStrikeStack) && ((MyAuraTimeLeft("Frost Fever", Me.get_CurrentTarget()) > 8000.0) && (MyAuraTimeLeft("Blood Plague", Me.get_CurrentTarget()) > 8000.0)))) && (((Me.BloodRuneCount > 0) && (Me.FrostRuneCount == 0)) && CanCastCheck("Blood Boil", false))) && !HasEnemyNearGotCCBreakonDamge(Me.get_CurrentTarget(), (float) (10 + GlyphprivateofPestilenceBonus)), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Blood Boil", Me.get_CurrentTarget(), "BloodBoilRoilingBloodConversion");
                LastSpreadDiseases = DateTime.Now + TimeSpan.FromMilliseconds(2000.0);
            }));
        }

        private static Composite BloodBoilUnholyAoE()
        {
            return (Composite) new Decorator(ret => (THSettings.Instance.BloodBoil && CurrentTargetAttackable(10.0, false, false)) && CanCastCheck("Blood Boil", false), (Composite) new Styx.TreeSharp.Action(delegate (object ret) {
                CastSpell("Blood Boil", (WoWUnit) Me, "BloodBoilUnholyAoE");
            }));
        }

        private static Composite BloodFury()
        {
            Composite[] compositeArray = new Composite[] { (Composite) new Decorator(delegate (object ret) {
                if (((!THSettings.Instance.AutoRacial || !Me.Combat) || !CurrentTargetAttackable(5.0, false, false)) || (!MeHasAura(0xc847) && !MeHasAura(0xbf78)))
                {
                    return false;
                }
                return CanCastCheck("Blood Fury", true);
            }, (Composite) new Styx.TreeSharp.Action(delegate (object ret) {
                CastSpell("Blood Fury", (WoWUnit) Me, "");
                return (RunStatus) RunStatus.Failure;
            })), (Composite) new Decorator(delegate (object ret) {
                if (((!THSettings.Instance.AutoRacial || !Me.Combat) || !CurrentTargetAttackable(5.0, false, false)) || (!MeHasAura(0xc847) && !MeHasAura(0xbf78)))
                {
                    return false;
                }
                return CanCastCheck("Berserking", true);
            }, (Composite) new Styx.TreeSharp.Action(delegate (object ret) {
                CastSpell("Berserking", (WoWUnit) Me, "");
                return (RunStatus) RunStatus.Failure;
            })) };
            return (Composite) new PrioritySelector(compositeArray);
        }

        private static Composite BloodPresenceSwap()
        {
            return (Composite) new Decorator(ret => (((THSettings.Instance.BloodPresence && ((PresenceSwapLast + TimeSpan.FromMilliseconds((double) THSettings.Instance.PresenceSwapTimeout)) < DateTime.Now)) && (!MeHasAura("Blood Presence") && (Me.HealthPercent <= THSettings.Instance.BloodPresenceHP))) && !Burst) && CanCastCheck("Blood Presence", false), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                PresenceSwapLast = DateTime.Now;
                CastSpell("Blood Presence", (WoWUnit) Me, "BloodPresence");
            }));
        }

        private static Composite BloodRotation()
        {
            Composite[] compositeArray = new Composite[] { 
                AutoTargetProt(), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                    if (((TreeRoot.get_Current().Name != "DungeonBuddy") && (Me.get_CurrentMap().IsDungeon || Me.get_CurrentMap().IsRaid)) && (((!Me.Combat && (Me.get_CurrentTarget() != null)) && (IsEnemy(Me.get_CurrentTarget()) && !Me.get_CurrentTarget().IsTargetingMyPartyMember)) && (!Me.get_CurrentTarget().IsTargetingMyRaidMember && !Me.get_CurrentTarget().IsTargetingMeOrPet)))
                    {
                        return (RunStatus) RunStatus.Success;
                    }
                    if (((THSettings.Instance.AutoAoE && (THSettings.Instance.UnittoStartAoE > 0)) && (!Me.get_CurrentMap().IsArena && !Me.get_CurrentMap().IsBattleground)) && (CountEnemyNear((WoWUnit) Me, 15f) >= THSettings.Instance.UnittoStartAoE))
                    {
                        _aoEModeOn = true;
                    }
                    else
                    {
                        _aoEModeOn = false;
                    }
                    return (RunStatus) RunStatus.Failure;
                }), MovementMoveStop(ret => Me.get_CurrentTarget(), 3.0), MovementMoveToMelee(ret => Me.get_CurrentTarget()), TargetMyPetTarget(), UseHealthstone(), UseBattleStandard(), EmpowerRuneWeapon(), BloodFury(), BoneShield(), VampiricBlood(), IceboundFortitude(), IceboundFortitudeStun(), DesecratedGround(), LichborneHeal(), AntiMagicShell(), 
                AntiMagicShellLichborne(), AntiMagicShellEnemy(), AntiMagicShellDebuff(), AntiMagicShellCaster(), RuneTap(), DarkCommand(), DarkSimulacrum(), DarkSimulacrumUse(), DeathGripTaunt(), DeathGripFarUnit(), DeathGrip(), DeathGripAsphyxiateHelpFriend(), DeathGripRemorselessWinter(), BloodTap(), DeathsAdvance(), StrangulateLow(), 
                DarkSimulacrumUse(), HornofWinterBuff(), RaiseAlly(), RaiseDead(), (Composite) new Decorator(ret => !_aoEModeOn, (Composite) new PrioritySelector(new Composite[] { 
                    AttackASAP(), DarkSuccor(), SoulReaper(), GorefiendsGraspAoE(), GorefiendsGraspAggro(), GorefiendsGraspKiter(), GorefiendsGraspMelee(), RemorselessWinter(), RemorselessWinterEnemyLowHP(), RemorselessWinterEnemyNumber(), RemorselessWinterBurst(), DeathPact(), DeathSiphon(), Conversion(), DeathCoilHeal(), DancingRuneWeapon(), 
                    DeathStrikeBloodShield(), DeathStrikeBloodPvP(), ChainsofIce(), ChainsofIceMelee(), DeathandDecaySnare(), PlagueLeech(), Outbreak(), UnholyBlight(), BloodBoilProc(), RuneStrikeCap(), IcyTouchDebuffBlood(), BloodBoilRoilingBlood(), Pestilence(), PlagueStrikeDebuff(), NecroticStrikeStack(), DeathStrikeBlood(), 
                    ControlUndead(), ControlUndeadUpdate(), HeartStrike(), RuneStrike(), BloodStrike(), HornofWinter(), Presence(), DeathCoilBloodFrost(), PathofFrost()
                 })), (Composite) new Decorator(ret => _aoEModeOn, (Composite) new PrioritySelector(new Composite[] { 
                    DarkSuccor(), SoulReaper(), DancingRuneWeapon(), DeathStrikeBloodShield(), DeathStrikeBloodPvP(), ChainsofIce(), DeathPact(), DeathSiphon(), Conversion(), PlagueLeech(), Outbreak(), BloodBoilProc(), RuneStrikeCap(), UnholyBlight(), BloodBoilRefreshDebuffAoE(), DeathStrikeBlood(), 
                    IcyTouchDebuffBloodAoE(), PlagueStrikeBloodAoE(), BloodBoilRoilingBlood(), Pestilence(), BloodBoil4Unit(), DeathandDecay(), HeartStrikeAoE(), RuneStrike(), HornofWinter(), Presence(), PathofFrost()
                 })), RestRotation()
             };
            return (Composite) new PrioritySelector(compositeArray);
        }

        private static Composite BloodStrike()
        {
            return (Composite) new Decorator(ret => ((((UseSpecialization == 1) && !SpellManager.HasSpell("Heart Strike")) || ((UseSpecialization == 3) && !SpellManager.HasSpell("Festering Strike"))) && (CurrentTargetAttackable(5.0, false, false) && FacingOverride(Me.get_CurrentTarget()))) && CanCastCheck("Blood Strike", false), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Blood Strike", Me.get_CurrentTarget(), "BloodStrike");
            }));
        }

        private static Composite BloodStrikeConversion()
        {
            return (Composite) new Decorator(ret => (((CurrentTargetAttackable(5.0, false, false) && FacingOverride(Me.get_CurrentTarget())) && (THSettings.Instance.NecroticStrikeStack && (Me.BloodRuneCount > 0))) && (Me.FrostRuneCount == 0)) && CanCastCheck("Blood Strike", false), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Blood Strike", Me.get_CurrentTarget(), "BloodStrikeConversion");
            }));
        }

        private static Composite BloodTap()
        {
            return (Composite) new Decorator(delegate (object ret) {
                if ((((!THSettings.Instance.BloodTap || ((BloodTapLast + TimeSpan.FromMilliseconds(2000.0)) >= DateTime.Now)) || (!(LastCastSpell != "Blood Tap") || !Me.Combat)) || ((!CurrentTargetAttackable(10.0, false, false) || !MeHasAura("Blood Charge")) || (MyTotalActiveRune() >= 6))) || ((((!Burst && !MeHasAura("Pillar of Frost")) && !MeHasAura("Unholy Frenzy")) || (MyAuraStackCount("Blood Charge", (WoWUnit) Me) < 5.0)) && (MyAuraStackCount("Blood Charge", (WoWUnit) Me) < THSettings.Instance.BloodChargeStack)))
                {
                    return false;
                }
                return CanCastCheck("Blood Tap", true);
            }, (Composite) new Styx.TreeSharp.Action(delegate (object ret) {
                BloodTapLast = DateTime.Now;
                CastSpell("Blood Tap", (WoWUnit) Me, "");
                SpellsCooldownCache.Clear();
                return (RunStatus) RunStatus.Failure;
            }));
        }

        private static Composite BoneShield()
        {
            return (Composite) new Decorator(ret => ((THSettings.Instance.BoneShield && !MeHasAura("Bone Shield")) && !Me.InVehicle) && CanCastCheck("Bone Shield", true), (Composite) new Styx.TreeSharp.Action(delegate (object ret) {
                CastSpell("Bone Shield", (WoWUnit) Me, "");
                return (RunStatus) RunStatus.Failure;
            }));
        }

        private static bool BuffBurst(WoWUnit target)
        {
            if (Me.get_CurrentMap().IsRaid)
            {
                return false;
            }
            return target.GetAllAuras().Any<WoWAura>(aura => BuffBurstHS.Contains(aura.SpellId));
        }

        private static bool BuffEnrage(WoWUnit target)
        {
            if (Me.get_CurrentMap().IsRaid)
            {
                return false;
            }
            return target.GetAllAuras().Any<WoWAura>(delegate (WoWAura aura) {
                if (!BuffEnrageHS.Contains(aura.SpellId))
                {
                    return (aura.get_Spell().get_DispelType() == ((WoWDispelType) ((int) WoWDispelType.Enrage)));
                }
                return true;
            });
        }

        private static bool BuffHeal(WoWUnit target)
        {
            if (Me.get_CurrentMap().IsRaid)
            {
                return false;
            }
            return target.GetAllAuras().Any<WoWAura>(aura => BuffHealHS.Contains(aura.SpellId));
        }

        private static WoWPoint CalculateDropLocation(WoWUnit target)
        {
            if (!IsMoving(target) || target.get_MovementInfo().MovingBackward)
            {
                return target.get_Location();
            }
            return WoWMathHelper.CalculatePointBehind(target.get_Location(), target.Rotation, -(5f + target.get_MovementInfo().RunSpeed));
        }

        private static bool CanCastCheck(string spellName, bool IsOffGCDSpell = false)
        {
            bool flag;
            if (!SpellManager.HasSpell(spellName))
            {
                return false;
            }
            if ((spellName == "Death Grip") && MeHasAura(0x201db))
            {
                return true;
            }
            if ((Me.get_CurrentMap().IsArena || Me.get_CurrentMap().IsBattleground) && ((((spellName != "Lichborne") && (spellName != " Icebound Fortitude")) && ((spellName != "Desecrated Ground") && (spellName != "Every Man for Himself"))) && DebuffCC((WoWUnit) Me)))
            {
                return false;
            }
            double spellPowerCost = GetSpellPowerCost(spellName);
            if (spellPowerCost < 1.0)
            {
                flag = false;
            }
            else
            {
                flag = true;
            }
            if (flag)
            {
                if (((spellName == "Death Coil") && MeHasAura(0x13dbc)) && MeHasAura("Unholy Presence"))
                {
                    spellPowerCost = 0.0;
                }
                if (PlayerRunicPower() < spellPowerCost)
                {
                    return false;
                }
            }
            if ((spellName == "Army of the Dead") && IsMoving((WoWUnit) Me))
            {
                return false;
            }
            return SpellManager.CanCast(spellName);
        }

        private static void CancelAura(int HealthPercent)
        {
            WoWAura auraByName = Me.GetAuraByName("Conversion");
            if (((Me.HealthPercent >= HealthPercent) && (auraByName != null)) && auraByName.Cancellable)
            {
                auraByName.TryCancelAura();
            }
        }

        private static void CancelAura(string AuraName)
        {
            WoWAura auraByName = Me.GetAuraByName(AuraName);
            if ((auraByName != null) && auraByName.Cancellable)
            {
                auraByName.TryCancelAura();
            }
        }

        private static bool CanIcyTouchDispel(WoWUnit target)
        {
            if (((target == null) || !target.IsValid) || !target.IsPlayer)
            {
                return false;
            }
            return target.get_Buffs().Values.Any<WoWAura>(buffs => (buffs.get_Spell().get_DispelType() == ((WoWDispelType) ((int) WoWDispelType.Magic))));
        }

        private static bool CanUseCheck(WoWItem Item)
        {
            ItemsCooldownCacheClear();
            if (!ItemsCooldownCache.ContainsKey(Item))
            {
                ItemCooldownBack = GetItemCooldown(Item);
                if (ItemCooldownBack.TotalMilliseconds <= 0.0)
                {
                    return true;
                }
                ItemsCooldownCacheAdd(Item, DateTime.Now + ItemCooldownBack);
            }
            return false;
        }

        private static bool CanUseDeathRune()
        {
            if ((THSettings.Instance.NecroticStrikeStack && SpellManager.HasSpell("Necrotic Strike")) && ((Me.DeathRuneCount <= THSettings.Instance.NecroticStrikeDeathRuneNumber) && ((UseSpecialization != 2) || (Me.DeathRuneCount < 2))))
            {
                return false;
            }
            return true;
        }

        private static bool CanUseEquippedItem(WoWItem item)
        {
            if (string.IsNullOrEmpty(Lua.GetReturnVal<string>("return GetItemSpell(" + item.Entry + ")", 0)))
            {
                return false;
            }
            return (item.Usable && (item.Cooldown <= 0f));
        }

        private static bool Casting()
        {
            return (Me.IsCasting || Me.IsChanneling);
        }

        private static bool CastingorGCDL()
        {
            if (!Casting())
            {
                return GCDL();
            }
            return true;
        }

        private static void CastSpell(string spellName, WoWUnit target, string reason = "")
        {
            SpellManager.Cast(spellName, target);
            LastCastSpell = spellName;
            LastCastUnit = target;
            LastCastTime = DateTime.Now;
            if (THSettings.Instance.AutoWriteLog && (LastWriteLog <= DateTime.Now))
            {
                LastWriteLog = DateTime.Now + TimeSpan.FromMilliseconds(MyLatency);
                if (((((spellName == "Mind Freeze") || (spellName == "Strangulate")) || ((spellName == "Asphyxiate") || (spellName == "Incebound Fortitude"))) || (((spellName == "Lichborne") || (spellName == "Death Grip")) || ((spellName == "Pillar of Frost") || (spellName == "Unholy Frenzy")))) || ((((spellName == "Empower Rune Weapon") || (spellName == "Summon Gargoyle")) || ((spellName == "Dark Transformation") || (spellName == "Desecrated Ground"))) || ((spellName == "Anti-Magic Zone") || (spellName == "Anti-Magic Shell"))))
                {
                    colorlog = Colors.GhostWhite;
                }
                else if (target == Me)
                {
                    colorlog = Colors.GreenYellow;
                }
                else if (target == Me.get_CurrentTarget())
                {
                    colorlog = Colors.Yellow;
                }
                else
                {
                    colorlog = Colors.YellowGreen;
                }
                string str = string.Concat(new object[] { "RP: ", PlayerRunicPower(), " (B:", Me.BloodRuneCount, " D:", Me.DeathRuneCount, " F:", Me.FrostRuneCount, " U:", Me.UnholyRuneCount, ")" });
                Styx.Common.Logging.Write(colorlog, string.Concat(new object[] { DateTime.Now.ToString("ss:fff"), " HP: ", Math.Round(Me.HealthPercent), "% ", str, " ", target.SafeName, " ", Math.Round(target.Distance, 2), "y ", Math.Round(target.HealthPercent), "% hp ", spellName, " (", reason, ") " }));
            }
        }

        private static Composite ChainsofIce()
        {
            return (Composite) new Decorator(delegate (object ret) {
                if ((((!THSettings.Instance.ChainsofIce || ((LastGripSnare + TimeSpan.FromSeconds(2.0)) >= DateTime.Now)) || (!CurrentTargetAttackable(30.0, false, false) || (GetDistance(Me.get_CurrentTarget()) <= 5f))) || ((InvulnerableSpell(Me.get_CurrentTarget()) || InvulnerableRootandSnare(Me.get_CurrentTarget())) || DebuffRootorSnare(Me.get_CurrentTarget()))) || (!CanUseDeathRune() && (Me.FrostRuneCount <= 0)))
                {
                    return false;
                }
                return CanCastCheck("Chains of Ice", false);
            }, (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                LastGripSnare = DateTime.Now;
                CastSpell("Chains of Ice", Me.get_CurrentTarget(), "");
                LastChainsofIce = DateTime.Now;
            }));
        }

        private static Composite ChainsofIceMelee()
        {
            return (Composite) new Decorator(ret => (((((THSettings.Instance.ChainofIceMelee && ((LastGripSnare + TimeSpan.FromSeconds(2.0)) < DateTime.Now)) && (((LastChainsofIceMelee + TimeSpan.FromSeconds(2.0)) < DateTime.Now) && Me.Combat)) && (Me.get_CurrentMap().IsArena || Me.get_CurrentMap().IsBattleground)) && (CanUseDeathRune() || (Me.BloodRuneCount > 0))) && CanCastCheck("Chains of Ice", false)) && GetUnitChainsofIceMelee(), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                LastGripSnare = DateTime.Now;
                CastSpell("Chains of Ice", UnitChainsofIceMelee, "ChaisnofIceMelee");
                LastChainsofIceMelee = DateTime.Now;
            }));
        }

        private static void ChatFilter(Chat.ChatSimpleMessageEventArgs e)
        {
            if (THSettings.Instance.FlagReturnorPickup && (((Battlegrounds.get_Current() == ((BattlegroundType) ((int) BattlegroundType.WSG))) || (Battlegrounds.get_Current() == ((BattlegroundType) ((int) BattlegroundType.TP)))) || (Battlegrounds.get_Current() == ((BattlegroundType) ((int) BattlegroundType.EotS)))))
            {
                if (e.Message.Contains("Flag was dropped by"))
                {
                    SearchFlagTime = DateTime.Now + TimeSpan.FromSeconds(10.0);
                }
                else if ((SearchFlagTime > DateTime.Now) && e.Message.Contains("Flag was returned to its base by"))
                {
                    SearchFlagTime = DateTime.Now - TimeSpan.FromSeconds(10.0);
                }
            }
        }

        private static Composite ControlUndead()
        {
            return (Composite) new Decorator(ret => (((THSettings.Instance.ControlUndead && !Me.GotAlivePet) && (((LastControlUndead + TimeSpan.FromMilliseconds(10000.0)) < DateTime.Now) && !IsMoving((WoWUnit) Me))) && CanCastCheck("Control Undead", false)) && GetUnitControlUndead(), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                LastControlUndead = DateTime.Now;
                SafelyFacingTarget(UnitControlUndead);
                CastSpell("Control Undead", UnitControlUndead, "");
                UnitControlUndeadLast = UnitControlUndead;
            }));
        }

        private static Composite ControlUndeadUpdate()
        {
            return (Composite) new Decorator(ret => ((THSettings.Instance.ControlUndead && ((CanControlUndeadLast + TimeSpan.FromMinutes(1.0)) < DateTime.Now)) && Me.GotAlivePet) && !CanControlUndead.Contains(Me.get_Pet().Entry), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CanControlUndead.Add(Me.get_Pet().Entry);
                CanControlUndeadLast = DateTime.Now;
                return (RunStatus) RunStatus.Failure;
            }));
        }

        private static Composite Conversion()
        {
            Composite[] compositeArray = new Composite[] { (Composite) new Decorator(delegate (object ret) {
                if (((!THSettings.Instance.HealAttack || MeHasAura("Conversion")) || ((PlayerRunicPower() < 5.0) || HoldSpendingRunicPower())) || ((Me.HealthPercent > THSettings.Instance.HealAttackHP) && (Me.Combat || (Me.HealthPercent > 85.0))))
                {
                    return false;
                }
                return CanCastCheck("Conversion", false);
            }, (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Conversion", (WoWUnit) Me, "Conversion");
            })), (Composite) new Decorator(delegate (object ret) {
                if ((((!THSettings.Instance.HealAttack || !Me.Combat) || (!MeHasAura("Conversion") || (PlayerRunicPower() < 5.0))) || HoldSpendingRunicPower()) || (((Me.HealthPercent > (THSettings.Instance.HealAttackHP - 20)) || CurrentTargetAttackable(5.0, false, false)) && (Me.HealthPercent > THSettings.Instance.UrgentHeal)))
                {
                    return false;
                }
                return CanCastCheck("Conversion", false);
            }, (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CancelAura("Conversion");
                CastSpell("Conversion", (WoWUnit) Me, "Double Conversion");
            })) };
            return (Composite) new PrioritySelector(compositeArray);
        }

        private static double CountDebuff(WoWUnit u)
        {
            if (((u == null) || !u.IsValid) || !u.IsAlive)
            {
                return 0.0;
            }
            return (double) u.get_Debuffs().Values.Count<WoWAura>(delegate (WoWAura debuff) {
                if ((debuff.get_Spell().get_DispelType() != ((WoWDispelType) ((int) WoWDispelType.Magic))) && (debuff.get_Spell().get_DispelType() != ((WoWDispelType) ((int) WoWDispelType.Poison))))
                {
                    return (debuff.get_Spell().get_DispelType() == ((WoWDispelType) ((int) WoWDispelType.Disease)));
                }
                return true;
            });
        }

        private static double CountDebuffAll(WoWUnit u)
        {
            if (((u != null) && u.IsValid) && u.IsAlive)
            {
                return (double) u.get_Debuffs().Values.Count<WoWAura>();
            }
            return 0.0;
        }

        private static double CountDebuffMagic(WoWUnit u)
        {
            if (((u == null) || !u.IsValid) || !u.IsAlive)
            {
                return 0.0;
            }
            return (double) u.get_Debuffs().Values.Count<WoWAura>(debuff => (debuff.get_Spell().get_DispelType() == ((WoWDispelType) ((int) WoWDispelType.Magic))));
        }

        private static double CountDebuffRootandSnareMechanic(WoWUnit u)
        {
            if (((u == null) || !u.IsValid) || !u.IsAlive)
            {
                return 0.0;
            }
            return (double) u.GetAllAuras().Count<WoWAura>(delegate (WoWAura debuff) {
                if (debuff.get_Spell().get_Mechanic() != ((WoWSpellMechanic) ((int) WoWSpellMechanic.Snared)))
                {
                    return (debuff.get_Spell().get_Mechanic() == ((WoWSpellMechanic) ((int) WoWSpellMechanic.Rooted)));
                }
                return true;
            });
        }

        private static int CountDPSTarget(WoWUnit target)
        {
            Func<WoWUnit, bool> predicate = null;
            Func<WoWUnit, bool> func2 = null;
            if (Me.get_CurrentMap().IsArena || Me.get_CurrentMap().IsBattleground)
            {
                if (predicate == null)
                {
                    predicate = delegate (WoWUnit unit) {
                        if (((!BasicCheck(unit) || (unit.get_CurrentTarget() == null)) || (!unit.get_CurrentTarget().IsValid || (unit.get_CurrentTarget() != target))) || ((((TalentSort(unit) < 2) || (TalentSort(unit) > 3)) || (unit.get_Location().Distance(target.get_Location()) >= 40f)) && ((TalentSort(unit) != 1) || (unit.get_Location().Distance(target.get_Location()) >= 15f))))
                        {
                            return false;
                        }
                        return !DebuffCC(unit);
                    };
                }
                return NearbyUnFriendlyPlayers.Count<WoWUnit>(predicate);
            }
            if (func2 == null)
            {
                func2 = unit => ((BasicCheck(unit) && (unit.get_CurrentTarget() != null)) && (unit.get_CurrentTarget().IsValid && (unit.get_CurrentTarget() == target))) && !DebuffCC(unit);
            }
            return NearbyUnFriendlyUnits.Count<WoWUnit>(func2);
        }

        private static double CountEnemyNear(WoWUnit unitCenter, float distance)
        {
            return (double) FarUnFriendlyUnits.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck)).Count<WoWUnit>(delegate (WoWUnit unit) {
                if ((!(Me.get_CurrentMap().Name == "Proving Grounds") && !IsDummy(unit)) && ((!unit.Combat || (unit.MaxHealth <= (MeMaxHealth * 0.2))) || (!unit.GotTarget || !FarFriendlyUnits.Contains(unit.get_CurrentTarget()))))
                {
                    return false;
                }
                return (GetDistance(unitCenter, unit) <= distance);
            });
        }

        private static double CountEnemyNearGorefiendsGraspAoE(WoWUnit unitCenter, float distance, string spellName)
        {
            return (double) NearbyUnFriendlyUnits.Count<WoWUnit>(unit => (((BasicCheck(unit) && (unitCenter.get_Location().Distance(unit.get_Location()) <= distance)) && (!DebuffCC(unit) && !DebuffRoot(unit))) && !UnitHasAura(spellName, unit)));
        }

        private static double CountEnemyNearGotCCBreakonDamge(WoWUnit unitCenter, float distance)
        {
            return (double) FarUnFriendlyPlayers.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck)).Count<WoWUnit>(unit => ((((unit.MaxHealth > (MeMaxHealth * 0.3)) && (((Me.get_CurrentMap().Name == "Proving Grounds") || IsDummy(unit)) || (unit.Combat && FarFriendlyPlayers.Contains(unit.get_CurrentTarget())))) && (GetDistance(unitCenter, unit) <= distance)) && DebuffCCBreakonDamage(unit)));
        }

        private static double CountEnemyNearNoCC(WoWUnit unitCenter, float distance)
        {
            return (double) NearbyUnFriendlyUnits.Count<WoWUnit>(delegate (WoWUnit unit) {
                if ((!BasicCheck(unit) || (unitCenter.get_Location().Distance(unit.get_Location()) > distance)) || (unit.IsPet || DebuffCC(unit)))
                {
                    return false;
                }
                return (((Me.get_CurrentMap().Name == "Proving Grounds") || IsDummy(unit)) || ((unit.Combat && unit.GotTarget) && FarFriendlyPlayers.Contains(unit.get_CurrentTarget())));
            });
        }

        private static double CountEneyTargettingUnit(WoWUnit target, float distance)
        {
            return (from unit in NearbyUnFriendlyUnits
                where (((BasicCheck(unit) && (unit.Distance < distance)) && ((unit.get_CurrentTarget() != null) && unit.get_CurrentTarget().IsValid)) && ((unit.Level <= (target.Level + 3)) && !unit.IsPet)) && (unit.get_CurrentTarget() == target)
                select unit).Aggregate<WoWUnit, double>(0.0, (current, unit) => (current + 1.0));
        }

        private static int CountMagicDPSTarget(WoWUnit target)
        {
            Func<WoWUnit, bool> predicate = null;
            Func<WoWUnit, bool> func2 = null;
            if (Me.get_CurrentMap().IsArena || Me.get_CurrentMap().IsBattleground)
            {
                if (predicate == null)
                {
                    predicate = unit => (((BasicCheck(unit) && (unit.get_CurrentTarget() != null)) && (unit.get_CurrentTarget().IsValid && (unit.get_CurrentTarget() == target))) && ((TalentSort(unit) == 3) && (unit.get_Location().Distance(target.get_Location()) < 40f))) && !DebuffCC(unit);
                }
                return NearbyUnFriendlyPlayers.Count<WoWUnit>(predicate);
            }
            if (func2 == null)
            {
                func2 = unit => (((BasicCheck(unit) && (unit.get_CurrentTarget() != null)) && (unit.get_CurrentTarget().IsValid && (unit.get_CurrentTarget() == target))) && ((unit.get_PowerType() == ((WoWPowerType) ((int) WoWPowerType.Mana))) && (unit.get_Location().Distance(target.get_Location()) < 40f))) && !DebuffCC(unit);
            }
            return NearbyUnFriendlyUnits.Count<WoWUnit>(func2);
        }

        private static int CountMeleeDPSTarget(WoWUnit target, double distance)
        {
            Func<WoWUnit, bool> predicate = null;
            Func<WoWUnit, bool> func2 = null;
            if (Me.get_CurrentMap().IsArena || Me.get_CurrentMap().IsBattleground)
            {
                if (predicate == null)
                {
                    predicate = unit => (((BasicCheck(unit) && (unit.get_CurrentTarget() != null)) && (unit.get_CurrentTarget().IsValid && (unit.get_CurrentTarget() == target))) && ((TalentSort(unit) == 1) && (unit.get_Location().Distance(target.get_Location()) <= distance))) && !DebuffCC(unit);
                }
                return NearbyUnFriendlyPlayers.Count<WoWUnit>(predicate);
            }
            if (func2 == null)
            {
                func2 = unit => (((BasicCheck(unit) && (unit.get_CurrentTarget() != null)) && (unit.get_CurrentTarget().IsValid && (unit.get_CurrentTarget() == target))) && (unit.get_Location().Distance(target.get_Location()) <= distance)) && !DebuffCC(unit);
            }
            return NearbyUnFriendlyUnits.Count<WoWUnit>(func2);
        }

        private static int CountMeleeFriendDPSTarget(WoWUnit target, double distance)
        {
            Func<WoWUnit, bool> predicate = null;
            Func<WoWUnit, bool> func2 = null;
            if (Me.get_CurrentMap().IsArena || Me.get_CurrentMap().IsBattleground)
            {
                if (predicate == null)
                {
                    predicate = unit => (((BasicCheck(unit) && (unit.get_CurrentTarget() != null)) && (unit.get_CurrentTarget().IsValid && (unit.get_CurrentTarget() == target))) && ((TalentSort(unit) == 1) && (unit.get_Location().Distance(target.get_Location()) <= distance))) && !DebuffCC(unit);
                }
                return FarFriendlyPlayers.Count<WoWUnit>(predicate);
            }
            if (func2 == null)
            {
                func2 = unit => (((BasicCheck(unit) && (unit.get_CurrentTarget() != null)) && (unit.get_CurrentTarget().IsValid && (unit.get_CurrentTarget() == target))) && (unit.get_Location().Distance(target.get_Location()) <= distance)) && !DebuffCC(unit);
            }
            return FarFriendlyPlayers.Count<WoWUnit>(func2);
        }

        private static int CountPhysicDPSTarget(WoWUnit target)
        {
            Func<WoWUnit, bool> predicate = null;
            Func<WoWUnit, bool> func2 = null;
            if (Me.get_CurrentMap().IsArena || Me.get_CurrentMap().IsBattleground)
            {
                if (predicate == null)
                {
                    predicate = delegate (WoWUnit unit) {
                        if (((!BasicCheck(unit) || (unit.get_CurrentTarget() == null)) || (!unit.get_CurrentTarget().IsValid || (unit.get_CurrentTarget() != target))) || (((TalentSort(unit) != 2) || (unit.get_Location().Distance(target.get_Location()) >= 40f)) && ((TalentSort(unit) != 1) || (unit.get_Location().Distance(target.get_Location()) >= 25f))))
                        {
                            return false;
                        }
                        return !DebuffCC(unit);
                    };
                }
                return NearbyUnFriendlyPlayers.Count<WoWUnit>(predicate);
            }
            if (func2 == null)
            {
                func2 = unit => (((BasicCheck(unit) && (unit.get_CurrentTarget() != null)) && (unit.get_CurrentTarget().IsValid && (unit.get_CurrentTarget() == target))) && (unit.get_Location().Distance(target.get_Location()) < 15f)) && !DebuffCC(unit);
            }
            return NearbyUnFriendlyUnits.Count<WoWUnit>(func2);
        }

        internal static string CreateMD5Hash(string input)
        {
            byte[] bytes = Encoding.ASCII.GetBytes(input);
            return BitConverter.ToString(MD5.Create().ComputeHash(bytes)).Replace("-", "").ToLower();
        }

        private static bool CurrentTargetAttackable(double distance, bool includeCurrentTargetCheckInvulnerableePhysic = false, bool includeCurrentTargetCheckInvulnerableeMagic = false)
        {
            if (((Me.get_CurrentTarget() == null) || !Me.get_CurrentTarget().IsValid) || (!Me.get_CurrentTarget().Attackable || !Me.get_CurrentTarget().IsAlive))
            {
                return false;
            }
            if (Me.get_CurrentTarget() != CurrentTargetCheckLast)
            {
                CurrentTargetCheck();
            }
            return (((((CurrentTargetCheckIsEnemy && !CurrentTargetCheckDebuffCCBreakonDamage) && !CurrentTargetCheckInvulnerable) && ((CurrentTargetCheckFacing || THSettings.Instance.AutoFace) || !IsOverrideModeOn)) && (!includeCurrentTargetCheckInvulnerableePhysic || !CurrentTargetCheckInvulnerablePhysic)) && ((!includeCurrentTargetCheckInvulnerableeMagic || !CurrentTargetCheckInvulnerableMagic) && ((CurrentTargetCheckDist <= distance) && CurrentTargetCheckInLineOfSpellSight)));
        }

        private static bool CurrentTargetAttackableNoLoS(double distance)
        {
            if (((Me.get_CurrentTarget() == null) || !Me.get_CurrentTarget().IsValid) || (!Me.get_CurrentTarget().Attackable || !Me.get_CurrentTarget().IsAlive))
            {
                return false;
            }
            if (Me.get_CurrentTarget() != CurrentTargetCheckLast)
            {
                CurrentTargetCheck();
            }
            return ((!CurrentTargetCheckDebuffCCBreakonDamage && !CurrentTargetCheckInvulnerable) && (CurrentTargetCheckIsEnemy && (CurrentTargetCheckDist <= distance)));
        }

        private static void CurrentTargetCheck()
        {
            if (CurrentTargetCheckLastTime <= DateTime.Now)
            {
                CurrentTargetCheckLastTime = DateTime.Now + CurrentTargetCheckTimeOut;
                if (BasicCheck(Me.get_CurrentTarget()))
                {
                    CurrentTargetCheckLast = Me.get_CurrentTarget();
                    CurrentTargetCheckFacing = Me.IsSafelyFacing((WoWObject) Me.get_CurrentTarget(), 180f);
                    CurrentTargetCheckDist = GetDistance(Me.get_CurrentTarget());
                    CurrentTargetCheckIsEnemy = IsEnemy(Me.get_CurrentTarget());
                    if (CurrentTargetCheckIsEnemy)
                    {
                        CurrentTargetCheckInvulnerable = Invulnerable(Me.get_CurrentTarget());
                        if (!CurrentTargetCheckInvulnerable)
                        {
                            CurrentTargetCheckDebuffCCBreakonDamage = DebuffCCBreakonDamage(Me.get_CurrentTarget());
                            if (!CurrentTargetCheckDebuffCCBreakonDamage)
                            {
                                CurrentTargetCheckInvulnerableMagic = InvulnerableSpell(Me.get_CurrentTarget());
                                CurrentTargetCheckInvulnerablePhysic = InvulnerablePhysic(Me.get_CurrentTarget());
                                if (CurrentTargetCheckDist <= 5.0)
                                {
                                    CurrentTargetCheckInLineOfSpellSight = true;
                                }
                                else if (InLineOfSpellSightCheck(Me.get_CurrentTarget()))
                                {
                                    CurrentTargetCheckInLineOfSpellSight = true;
                                }
                            }
                        }
                    }
                }
            }
        }

        private static Composite DancingRuneWeapon()
        {
            return (Composite) new Decorator(ret => ((((THSettings.Instance.DancingRuneWeapon && (Me.HealthPercent <= THSettings.Instance.DancingRuneWeaponHP)) && CurrentTargetAttackable(30.0, false, false)) && (((Me.get_CurrentTarget().CurrentHealth > (Me.CurrentHealth * 0.8)) || (Me.get_CurrentMap().Name == "Proving Grounds")) || (IsDummy(Me.get_CurrentTarget()) || Me.get_CurrentTarget().IsPlayer))) && FacingOverride(Me.get_CurrentTarget())) && CanCastCheck("Dancing Rune Weapon", true), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Dancing Rune Weapon", Me.get_CurrentTarget(), "DancingRuneWeapon");
                return (RunStatus) RunStatus.Failure;
            }));
        }

        private static Composite DarkCommand()
        {
            return (Composite) new Decorator(ret => ((THSettings.Instance.AutoTaunt && ((LastTaunt + TimeSpan.FromSeconds(1.0)) < DateTime.Now)) && (Me.Combat && CanCastCheck("Dark Command", true))) && GetUnitDarkCommand(), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Dark Command", UnitDarkCommand, "");
                LastTaunt = DateTime.Now;
                return (RunStatus) RunStatus.Failure;
            }));
        }

        private static Composite DarkSimulacrum()
        {
            return (Composite) new Decorator(ret => ((THSettings.Instance.DarkSimulacrumon && (THSettings.Instance.DarkSimulacrumonCast || THSettings.Instance.DarkSimulacrumonCooldown)) && (Me.Combat && CanCastCheck("Dark Simulacrum", true))) && GetUnitDarkSimulacrum(), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                FacingDelay = DateTime.Now;
                if ((THSettings.Instance.AutoFace && ((FacingDelay + TimeSpan.FromMilliseconds(100.0)) > DateTime.Now)) && !Me.IsFacing((WoWObject) UnitDarkSimulacrum))
                {
                    Me.SetFacing(UnitDarkSimulacrum);
                }
                CastSpell("Dark Simulacrum", UnitDarkSimulacrum, "");
                return (RunStatus) RunStatus.Failure;
            }));
        }

        private static Composite DarkSimulacrumUse()
        {
            Composite[] compositeArray = new Composite[] { (Composite) new Decorator(ret => ((THSettings.Instance.DarkSimulacrumonAuto && MeHasAura(0x12f30)) && (Me.get_CurrentPendingCursorSpell() != null)) && !Me.HasPendingSpell("Death and Decay"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                Styx.Common.Logging.Write("DarkSimulacrumUse Click " + Me.get_CurrentPendingCursorSpell().Name);
                SpellManager.ClickRemoteLocation(Me.get_Location());
                return (RunStatus) RunStatus.Failure;
            })), (Composite) new Decorator(ret => (THSettings.Instance.DarkSimulacrumonAuto && CurrentTargetAttackable(30.0, false, false)) && MeHasAura(0x12f30), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                Styx.Common.Logging.Write("DarkSimulacrumUse " + WoWSpell.FromId(0x12f26));
                SpellManager.Cast(0x12f26);
                return (RunStatus) RunStatus.Failure;
            })) };
            return (Composite) new PrioritySelector(compositeArray);
        }

        private static Composite DarkSuccor()
        {
            return (Composite) new Decorator(ret => (CurrentTargetAttackable(5.0, false, false) && MeHasAura(0x18cc0)) && FacingOverride(Me.get_CurrentTarget()), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Death Strike", Me.get_CurrentTarget(), "Dark Succor");
            }));
        }

        private static Composite DarkTransformation()
        {
            return (Composite) new Decorator(ret => ((Me.GotAlivePet && (MyAuraStackCount(0x164ce, (WoWUnit) Me) >= 5.0)) && CurrentTargetAttackable(30.0, false, false)) && CanCastCheck("Dark Transformation", false), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Dark Transformation", (WoWUnit) Me, "DarkTransformation");
            }));
        }

        private static Composite DeathandDecay()
        {
            return (Composite) new Decorator(delegate (object ret) {
                if (((!THSettings.Instance.DeathandDecay || IsMoving((WoWUnit) Me)) || !CurrentTargetAttackable(10.0, false, false)) || ((Me.get_CurrentTarget().CurrentHealth <= (Me.MaxHealth * 0.5)) && !IsDummy(Me.get_CurrentTarget())))
                {
                    return false;
                }
                return CanCastCheck("Death and Decay", false);
            }, (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                LastCastontheGround = DateTime.Now;
                CastSpell("Death and Decay", (WoWUnit) Me, "DeathandDecay");
                new Wait(TimeSpan.FromMilliseconds(300.0), ret => Me.HasPendingSpell("Death and Decay"), (Composite) new ActionAlwaysSucceed());
                LastCastontheGroundPosition = CalculateDropLocation(Me.get_CurrentTarget());
                SpellManager.ClickRemoteLocation(LastCastontheGroundPosition);
            }));
        }

        private static Composite DeathandDecayAoE()
        {
            return (Composite) new Decorator(delegate (object ret) {
                if ((!THSettings.Instance.DeathandDecay || !CurrentTargetAttackable(10.0, false, false)) || ((Me.get_CurrentTarget().CurrentHealth <= (Me.MaxHealth * 0.5)) && !IsDummy(Me.get_CurrentTarget())))
                {
                    return false;
                }
                return CanCastCheck("Death and Decay", false);
            }, (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                LastCastontheGround = DateTime.Now;
                CastSpell("Death and Decay", (WoWUnit) Me, "DeathandDecayAoE");
                new Wait(TimeSpan.FromMilliseconds(300.0), ret => Me.HasPendingSpell("Death and Decay"), (Composite) new ActionAlwaysSucceed());
                SpellManager.ClickRemoteLocation(Me.get_CurrentTarget().get_Location());
            }));
        }

        private static Composite DeathandDecayDW()
        {
            return (Composite) new Decorator(ret => (((THSettings.Instance.DeathandDecay && CurrentTargetAttackable(10.0, false, false)) && (IsDummy(Me.get_CurrentTarget()) || (Me.get_CurrentTarget().CurrentHealth > (Me.MaxHealth * 0.5)))) && CanCastCheck("Death and Decay", false)) && ((!SpellManager.HasSpell("Obliterate") || (SpellManager.HasSpell("Obliterate") && !CanCastCheck("Obliterate", false))) || (CountEnemyNear((WoWUnit) Me, 15f) > 1.0)), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                LastCastontheGround = DateTime.Now;
                CastSpell("Death and Decay", (WoWUnit) Me, "DeathandDecayDW");
                new Wait(TimeSpan.FromMilliseconds(300.0), ret => Me.HasPendingSpell("Death and Decay"), (Composite) new ActionAlwaysSucceed());
                SpellManager.ClickRemoteLocation(Me.get_CurrentTarget().get_Location());
            }));
        }

        private static Composite DeathandDecaySnare()
        {
            return (Composite) new Decorator(ret => (((((THSettings.Instance.DeathandDecaySnare && (LastCastSpell != "Death Grip")) && (HasGlyph.Contains("58629") && ((LastGripSnare + TimeSpan.FromSeconds(2.0)) < DateTime.Now))) && (CurrentTargetAttackable(30.0, false, false) && (CanUseDeathRune() || (Me.UnholyRuneCount > 0)))) && ((((Me.get_CurrentTarget().IsPlayer && (TalentSort(Me.get_CurrentTarget()) > 1)) && (Me.get_CurrentTarget().Distance >= THSettings.Instance.ChainsofIceMinDistance)) || ((Me.get_CurrentTarget().IsPlayer && (TalentSort(Me.get_CurrentTarget()) == 1)) && ((Me.get_CurrentTarget().Distance >= THSettings.Instance.ChainsofIceMinDistance) && !Me.get_CurrentTarget().IsSafelyFacing((WoWObject) Me)))) || (((Me.get_CurrentTarget().IsPlayer && (TalentSort(Me.get_CurrentTarget()) == 1)) && Me.get_CurrentTarget().IsSafelyBehind((WoWObject) Me)) || (Me.get_CurrentTarget().Fleeing && (Me.get_CurrentTarget().Distance >= THSettings.Instance.ChainsofIceMinDistance))))) && ((!InvulnerableSpell(Me.get_CurrentTarget()) && !InvulnerableRootandSnare(Me.get_CurrentTarget())) && !DebuffRootorSnare(Me.get_CurrentTarget()))) && CanCastCheck("Death and Decay", false), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                LastGripSnare = DateTime.Now;
                LastCastontheGround = DateTime.Now;
                CastSpell("Death and Decay", (WoWUnit) Me, "DeathandDecaySnare");
                new Wait(TimeSpan.FromMilliseconds(300.0), ret => Me.HasPendingSpell("Death and Decay"), (Composite) new ActionAlwaysSucceed());
                LastCastontheGroundPosition = CalculateDropLocation(Me.get_CurrentTarget());
                SpellManager.ClickRemoteLocation(LastCastontheGroundPosition);
            }));
        }

        private static Composite DeathCoilBloodFrost()
        {
            return (Composite) new Decorator(ret => (((THSettings.Instance.DeathCoil && CurrentTargetAttackable(30.0, false, false)) && (!HoldSpendingRunicPower() && (PlayerRunicPower() >= 80.0))) && (((GetDistance(Me.get_CurrentTarget()) > 5f) && !InvulnerableSpell(Me.get_CurrentTarget())) && FacingOverride(Me.get_CurrentTarget()))) && CanCastCheck("Death Coil", false), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Death Coil", Me.get_CurrentTarget(), "DeathCoilBloodFrost");
            }));
        }

        private static Composite DeathCoilCapRunicPower()
        {
            return (Composite) new Decorator(ret => (((THSettings.Instance.DeathCoil && CurrentTargetAttackable(30.0, false, false)) && (((LastCap + TimeSpan.FromMilliseconds(1000.0)) < DateTime.Now) && (PlayerRunicPower() >= 80.0))) && (!InvulnerableSpell(Me.get_CurrentTarget()) && FacingOverride(Me.get_CurrentTarget()))) && CanCastCheck("Death Coil", false), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                LastCap = DateTime.Now;
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Death Coil", Me.get_CurrentTarget(), "DeathCoilCapRunicPower");
            }));
        }

        private static Composite DeathCoilHeal()
        {
            return (Composite) new Decorator(ret => ((THSettings.Instance.LichborneHeal && MeHasAura("Lichborne")) && (Me.HealthPercent <= THSettings.Instance.DoNotHealAbove)) && CanCastCheck("Death Coil", false), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Death Coil", (WoWUnit) Me, "DeathCoilHeal");
            }));
        }

        private static Composite DeathCoilHealPet()
        {
            return (Composite) new Decorator(ret => (((((THSettings.Instance.DeathCoilHealPet && ((DeathCoilHealPetLast + TimeSpan.FromMilliseconds(2000.0)) < DateTime.Now)) && (!MeHasAura("Preparation") && !MeHasAura("Arena Preparation"))) && (Me.GotAlivePet && (Me.get_Pet().Distance < 30.0))) && ((Me.get_Pet().HealthPercent <= THSettings.Instance.DeathCoilHealPetHP) || ((!UnitHasAura("Dark Transformation", Me.get_Pet()) && !Me.Combat) && (MyAuraTimeLeft(0x164ce, (WoWUnit) Me) < 5000.0)))) && InLineOfSpellSightCheck(Me.get_Pet())) && CanCastCheck("Death Coil", false), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                DeathCoilHealPetLast = DateTime.Now;
                Lua.DoString("RunMacroText('/cast [@pet] Death Coil');", "WoW.lua");
                CastSpell("Death Coil", Me.get_Pet(), "DeathCoilHealPet");
            }));
        }

        private static Composite DeathCoilProc()
        {
            return (Composite) new Decorator(ret => (((THSettings.Instance.DeathCoil && CurrentTargetAttackable(30.0, false, false)) && (((LastProc + TimeSpan.FromMilliseconds(1000.0)) < DateTime.Now) && MeHasAura(0x13dbc))) && (!InvulnerableSpell(Me.get_CurrentTarget()) && FacingOverride(Me.get_CurrentTarget()))) && CanCastCheck("Death Coil", false), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                LastProc = DateTime.Now;
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Death Coil", Me.get_CurrentTarget(), "DeathCoilProc");
            }));
        }

        private static Composite DeathCoilShadowInfusion()
        {
            return (Composite) new Decorator(ret => (((THSettings.Instance.DeathCoil && CurrentTargetAttackable(30.0, false, false)) && (!HoldSpendingRunicPower() && FacingOverride(Me.get_CurrentTarget()))) && ((!InvulnerableSpell(Me.get_CurrentTarget()) && (MyAuraStackCount(0x164ce, (WoWUnit) Me) < 5.0)) && (Me.GotAlivePet && !UnitHasAura("Dark Transformation", Me.get_Pet())))) && CanCastCheck("Death Coil", false), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Death Coil", Me.get_CurrentTarget(), "DeathCoilShadowInfusion");
            }));
        }

        private static Composite DeathCoilUnholy()
        {
            return (Composite) new Decorator(ret => (((THSettings.Instance.DeathCoil && CurrentTargetAttackable(30.0, false, false)) && (!HoldSpendingRunicPower() && !InvulnerableSpell(Me.get_CurrentTarget()))) && FacingOverride(Me.get_CurrentTarget())) && CanCastCheck("Death Coil", false), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Death Coil", Me.get_CurrentTarget(), "DeathCoilUnholy");
            }));
        }

        private static Composite DeathGrip()
        {
            return (Composite) new Decorator(ret => (((((THSettings.Instance.DeathGrip && (THSettings.Instance.DeathGripMinDistance > 0)) && (((LastGripSnare + TimeSpan.FromSeconds(2.0)) < DateTime.Now) && CurrentTargetAttackable(30.0, false, false))) && ((!InvulnerableSpell(Me.get_CurrentTarget()) && !Me.get_CurrentTarget().IsBoss) && (Me.get_CurrentTarget().GotTarget && FacingOverride(Me.get_CurrentTarget())))) && ((!Me.get_CurrentTarget().Rooted && (Me.get_CurrentTarget().Distance >= THSettings.Instance.DeathGripMinDistance)) && (!IsMoving(Me.get_CurrentTarget()) || !Me.get_CurrentTarget().IsSafelyFacing((WoWObject) Me)))) && (!Me.get_CurrentTarget().get_Buffs().ContainsKey("Ring of Peace") && CanCastCheck("Death Grip", true))) && !HasMeleeFriendDPSTarget(Me.get_CurrentTarget(), 10.0), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                LastGripSnare = DateTime.Now;
                FacingDelay = DateTime.Now;
                if ((THSettings.Instance.AutoFace && ((FacingDelay + TimeSpan.FromMilliseconds(100.0)) > DateTime.Now)) && !Me.IsFacing((WoWObject) Me.get_CurrentTarget()))
                {
                    Me.SetFacing(Me.get_CurrentTarget());
                }
                CastSpell("Death Grip", Me.get_CurrentTarget(), "DeathGrip");
                LastTaunt = DateTime.Now;
                return (RunStatus) RunStatus.Failure;
            }));
        }

        private static Composite DeathGripAsphyxiateHelpFriend()
        {
            Composite[] compositeArray = new Composite[] { (Composite) new Decorator(ret => ((((THSettings.Instance.DeathGripMelee && ((LastGripSnare + TimeSpan.FromSeconds(2.0)) < DateTime.Now)) && Me.Combat) && (Me.get_CurrentMap().IsArena || Me.get_CurrentMap().IsBattleground)) && CanCastCheck("Death Grip", true)) && GetUnitDeathGripMelee(), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                LastGripSnare = DateTime.Now;
                FacingDelay = DateTime.Now;
                if ((THSettings.Instance.AutoFace && ((FacingDelay + TimeSpan.FromMilliseconds(100.0)) > DateTime.Now)) && !Me.IsFacing((WoWObject) UnitDeathGripMelee))
                {
                    Me.SetFacing(UnitDeathGripMelee);
                }
                CastSpell("Death Grip", UnitDeathGripMelee, "DeathGripMelee");
                return (RunStatus) RunStatus.Failure;
            })), (Composite) new Decorator(ret => (((THSettings.Instance.AsphyxiateHelpFriend && Me.Combat) && (Me.get_CurrentMap().IsArena || Me.get_CurrentMap().IsBattleground)) && CanCastCheck("Asphyxiate", true)) && GetUnitAsphyxiateHelpFriend(), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                LastGripSnare = DateTime.Now;
                FacingDelay = DateTime.Now;
                if ((THSettings.Instance.AutoFace && ((FacingDelay + TimeSpan.FromMilliseconds(100.0)) > DateTime.Now)) && !Me.IsFacing((WoWObject) UnitAsphyxiateHelpFriend))
                {
                    Me.SetFacing(UnitAsphyxiateHelpFriend);
                }
                CastSpell("Asphyxiate", UnitAsphyxiateHelpFriend, "Asphyxiate Help Friend");
                return (RunStatus) RunStatus.Failure;
            })) };
            return (Composite) new PrioritySelector(compositeArray);
        }

        private static Composite DeathGripFarUnit()
        {
            return (Composite) new Decorator(ret => (((THSettings.Instance.DeathGrip && ((LastTaunt + TimeSpan.FromSeconds(1.0)) < DateTime.Now)) && (Me.get_CurrentMap().IsDungeon || Me.get_CurrentMap().IsRaid)) && (Me.Combat && CanCastCheck("Death Grip", true))) && GetUnitDeathGripFarUnit(), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                FacingDelay = DateTime.Now;
                if ((THSettings.Instance.AutoFace && ((FacingDelay + TimeSpan.FromMilliseconds(100.0)) > DateTime.Now)) && !Me.IsFacing((WoWObject) UnitDeathGripFarUnit))
                {
                    Me.SetFacing(UnitDeathGripFarUnit);
                }
                CastSpell("Death Grip", UnitDeathGripFarUnit, "DeathGripFarUnit");
                LastTaunt = DateTime.Now;
                return (RunStatus) RunStatus.Failure;
            }));
        }

        private static void DeathGripInterruptVoid()
        {
            if (((THSettings.Instance.DeathGripInterrupt && ((LastInterrupt + TimeSpan.FromMilliseconds(1000.0)) < DateTime.Now)) && (Me.Combat && CanCastCheck("Death Grip", true))) && GetUnitDeathGripInterrupt())
            {
                if (Me.IsCasting)
                {
                    SpellManager.StopCasting();
                }
                FacingDelay = DateTime.Now;
                if ((THSettings.Instance.AutoFace && ((FacingDelay + TimeSpan.FromMilliseconds(100.0)) > DateTime.Now)) && !Me.IsFacing((WoWObject) UnitInterrupt))
                {
                    Me.SetFacing(UnitInterrupt);
                }
                if ((UnitInterrupt.IsCasting && (UnitInterrupt.CurrentCastTimeLeft.TotalMilliseconds > (MyLatency + 50.0))) || UnitInterrupt.IsChanneling)
                {
                    CastSpell("Death Grip", UnitInterrupt, "DeathGripInterrupt");
                    LastInterrupt = DateTime.Now;
                }
            }
        }

        private static Composite DeathGripRemorselessWinter()
        {
            return (Composite) new Decorator(ret => (((THSettings.Instance.RemorselessWinterDeathGrip && Me.Combat) && (Me.get_CurrentMap().IsArena || Me.get_CurrentMap().IsBattleground)) && (MeHasAura("Remorseless Winter") && CanCastCheck("Death Grip", true))) && GetUnitDeathGripRemorselessWinter(), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                FacingDelay = DateTime.Now;
                if ((THSettings.Instance.AutoFace && ((FacingDelay + TimeSpan.FromMilliseconds(100.0)) > DateTime.Now)) && !Me.IsFacing((WoWObject) UnitDeathGripRemorselessWinter))
                {
                    Me.SetFacing(UnitDeathGripRemorselessWinter);
                }
                CastSpell("Death Grip", UnitDeathGripRemorselessWinter, "DeathGripRemorselessWinter");
                return (RunStatus) RunStatus.Failure;
            }));
        }

        private static Composite DeathGripTaunt()
        {
            return (Composite) new Decorator(ret => ((THSettings.Instance.AutoTaunt && Me.Combat) && (((LastTaunt + TimeSpan.FromSeconds(1.0)) < DateTime.Now) && CanCastCheck("Death Grip", true))) && GetUnitDeathGripTaunt(), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                FacingDelay = DateTime.Now;
                if ((THSettings.Instance.AutoFace && ((FacingDelay + TimeSpan.FromMilliseconds(100.0)) > DateTime.Now)) && !Me.IsFacing((WoWObject) UnitDeathGripTaunt))
                {
                    Me.SetFacing(UnitDeathGripTaunt);
                }
                CastSpell("Death Grip", UnitDeathGripTaunt, "DeathGripTaunt");
                LastTaunt = DateTime.Now;
                return (RunStatus) RunStatus.Failure;
            }));
        }

        private static Composite DeathPact()
        {
            Composite[] compositeArray = new Composite[] { (Composite) new Decorator(delegate (object ret) {
                if (((!THSettings.Instance.HealAttack || !Me.Combat) || (Me.HealthPercent > THSettings.Instance.HealAttackHP)) || ((Me.get_Minions().Count <= 0) && !Me.GotAlivePet))
                {
                    return false;
                }
                return CanCastCheck("Death Pact", false);
            }, (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Death Pact", (WoWUnit) Me, "");
            })), (Composite) new Decorator(ret => (((THSettings.Instance.HealAttack && Me.Combat) && ((Me.HealthPercent <= THSettings.Instance.HealAttackHP) && (Me.get_Minions().Count == 0))) && (!Me.GotAlivePet && CanCastCheck("Death Pact", false))) && CanCastCheck("Raise Dead", false), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Raise Dead", (WoWUnit) Me, "DeathPact - Raise Dead");
            })) };
            return (Composite) new PrioritySelector(compositeArray);
        }

        private static Composite DeathRotation()
        {
            Composite[] compositeArray = new Composite[] { (Composite) new Styx.TreeSharp.Action(delegate (object r) {
                Styx.Common.Logging.Write("Waiting up to {0} seconds for clear area to use {1}...", new object[] { 10, SelfRezSpell });
            }), (Composite) new Wait(10, delegate (object until) {
                MobsNearby = CountEnemyNear((WoWUnit) Me, 20f);
                if ((MobsNearby > 0.0) && !Me.IsAlive)
                {
                    return Me.IsGhost;
                }
                return true;
            }, (Composite) new Styx.TreeSharp.Action(delegate (object r) {
                if (Me.IsGhost)
                {
                    Styx.Common.Logging.Write("Insignia taken or corpse release by something other than Singular...");
                    return (RunStatus) RunStatus.Failure;
                }
                if (Me.IsAlive)
                {
                    Styx.Common.Logging.Write("Ressurected by something other than Singular...");
                    return (RunStatus) RunStatus.Failure;
                }
                return (RunStatus) RunStatus.Success;
            })), (Composite) new DecoratorContinue(req => MobsNearby > 0.0, (Composite) new Styx.TreeSharp.Action(delegate (object r) {
                Styx.Common.Logging.Write("Still {0} enemies within {1} yds, skipping {2}", new object[] { MobsNearby, 20, SelfRezSpell });
                return (RunStatus) RunStatus.Failure;
            })), (Composite) new Styx.TreeSharp.Action(delegate (object r) {
                Styx.Common.Logging.Write("Ressurrecting Singular by invoking {0}...", new object[] { SelfRezSpell });
            }), (Composite) new Styx.TreeSharp.Action(delegate (object r) {
                Lua.DoString("UseSoulstone()", "WoW.lua");
            }), (Composite) new WaitContinue(1, delegate (object until) {
                if (!Me.IsAlive)
                {
                    return Me.IsGhost;
                }
                return true;
            }, (Composite) new ActionAlwaysSucceed()) };
            return (Composite) new Decorator(delegate (object req) {
                if (Me.IsAlive || Me.IsGhost)
                {
                    return false;
                }
                List<string> returnValues = Lua.GetReturnValues("return HasSoulstone()", "hawker.lua");
                if (((returnValues == null) || (returnValues.Count == 0)) || (string.IsNullOrEmpty(returnValues[0]) || (returnValues[0].ToLower() == "nil")))
                {
                    return false;
                }
                if (!THSettings.Instance.AutoMove)
                {
                    if (NextSuppressMessage < DateTime.Now)
                    {
                        NextSuppressMessage = DateTime.Now.AddSeconds(10.0);
                        Styx.Common.Logging.Write("Suppressing {0} behavior since movement disabled...", new object[] { returnValues[0] });
                    }
                    return false;
                }
                SelfRezSpell = returnValues[0];
                return true;
            }, (Composite) new Sequence(compositeArray));
        }

        private static Composite DeathsAdvance()
        {
            return (Composite) new Decorator(ret => ((THSettings.Instance.DeathsAdvance && CurrentTargetAttackable(30.0, false, false)) && ((GetDistance(Me.get_CurrentTarget()) > 5f) && DebuffRoot((WoWUnit) Me))) && CanCastCheck("Death's Advance", true), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Death's Advance", (WoWUnit) Me, "");
                return (RunStatus) RunStatus.Failure;
            }));
        }

        private Composite DeathSelector()
        {
            if (this._deathBehavior == null)
            {
                Styx.Common.Logging.Write("Initializing death behaviours.");
                this._deathBehavior = (Composite) new PrioritySelector(new Composite[] { DeathRotation() });
            }
            return null;
        }

        private static Composite DeathSiphon()
        {
            return (Composite) new Decorator(ret => (((THSettings.Instance.HealAttack && Me.Combat) && ((Me.HealthPercent <= THSettings.Instance.HealAttackHP) && CurrentTargetAttackable(30.0, false, false))) && FacingOverride(Me.get_CurrentTarget())) && CanCastCheck("Death Siphon", false), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Death Siphon", Me.get_CurrentTarget(), "");
            }));
        }

        private static Composite DeathStrike()
        {
            return (Composite) new Decorator(ret => (((THSettings.Instance.DeathStrike && (Me.HealthPercent <= THSettings.Instance.DeathStrikeHP)) && (CanUseDeathRune() || ((Me.FrostRuneCount > 0) && (Me.UnholyRuneCount > 0)))) && ((CurrentTargetAttackable(5.0, false, false) && (Me.get_CurrentTarget().CurrentHealth > Me.CurrentHealth)) && FacingOverride(Me.get_CurrentTarget()))) && CanCastCheck("Death Strike", false), (Composite) new Styx.TreeSharp.Action(delegate (object ret) {
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Death Strike", Me.get_CurrentTarget(), "");
            }));
        }

        private static Composite DeathStrikeBlood()
        {
            return (Composite) new Decorator(ret => ((THSettings.Instance.DeathStrikeBloodEnable && (CanUseDeathRune() || (Me.BloodRuneCount > 0))) && (CurrentTargetAttackable(5.0, false, false) && FacingOverride(Me.get_CurrentTarget()))) && CanCastCheck("Death Strike", false), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Death Strike", Me.get_CurrentTarget(), "DeathStrikeBlood");
            }));
        }

        private static Composite DeathStrikeBloodPvP()
        {
            return (Composite) new Decorator(ret => (((THSettings.Instance.DeathStrikeBloodEnable && (Me.get_CurrentMap().IsBattleground || Me.get_CurrentMap().IsArena)) && (CanUseDeathRune() || ((Me.UnholyRuneCount > 0) && (Me.FrostRuneCount > 0)))) && ((Me.HealthPercent <= THSettings.Instance.BloodPresenceHP) && CanCastCheck("Death Strike", false))) && GetUnitDeathStrikeBloodPvP(), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Death Strike", UnitDeathStrikeBloodPvP, "DeathStrikeBloodPvP");
            }));
        }

        private static Composite DeathStrikeBloodShield()
        {
            return (Composite) new Decorator(ret => (((THSettings.Instance.DeathStrikeBloodEnable && Me.get_CurrentMap().IsRaid) && (CurrentTargetAttackable(5.0, false, false) && FacingOverride(Me.get_CurrentTarget()))) && (MyAuraTimeLeft("Blood Shield", (WoWUnit) Me) < 2000.0)) && CanCastCheck("Death Strike", false), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Death Strike", Me.get_CurrentTarget(), "DeathStrikeBloodShield");
            }));
        }

        private static bool DebuffCC(WoWUnit target)
        {
            if (Me.get_CurrentMap().IsRaid)
            {
                return false;
            }
            return target.GetAllAuras().Any<WoWAura>(aura => DebuffCCHS.Contains(aura.SpellId));
        }

        private static bool DebuffCCBreakonDamage(WoWUnit target)
        {
            if (Me.get_CurrentMap().IsRaid)
            {
                return false;
            }
            return target.GetAllAuras().Any<WoWAura>(aura => DebuffCCBreakonDamageHS.Contains(aura.SpellId));
        }

        private static bool DebuffCCDuration(WoWUnit target, double duration, bool LogSpell = false)
        {
            if (Me.get_CurrentMap().IsRaid)
            {
                return false;
            }
            return target.GetAllAuras().Any<WoWAura>(aura => (DebuffCCDurationHS.Contains(aura.SpellId) && (aura.TimeLeft.TotalMilliseconds >= duration)));
        }

        private static bool DebuffCCleanseASAP(WoWUnit target)
        {
            if (Me.get_CurrentMap().IsRaid || (Me.get_CurrentMap().Name == "Proving Grounds"))
            {
                return target.GetAllAuras().Any<WoWAura>(aura => DebuffCCleanseASAPPvEHS.Contains(aura.SpellId));
            }
            if ((target.IsPlayer && (target.get_Class() == ((WoWClass) ((uint) WoWClass.Warrior)))) && target.GetAllAuras().Any<WoWAura>(aura => DebuffCCleanseASAPHSWarrior.Contains(aura.SpellId)))
            {
                return false;
            }
            return target.GetAllAuras().Any<WoWAura>(aura => (DebuffCCleanseASAPPvPHS.Contains(aura.SpellId) && (aura.TimeLeft.TotalMilliseconds > 3000.0)));
        }

        private static bool DebuffDisarm(WoWUnit target)
        {
            if (Me.get_CurrentMap().IsRaid)
            {
                return false;
            }
            return (target.Disarmed || target.GetAllAuras().Any<WoWAura>(aura => DebuffDisarmHS.Contains(aura.SpellId)));
        }

        private static bool DebuffDoNotCleanse(WoWUnit target)
        {
            return target.GetAllAuras().Any<WoWAura>(aura => DebuffDoNotCleanseHS.Contains(aura.SpellId));
        }

        private static bool DebuffDoNotHeal(WoWUnit target)
        {
            return target.GetAllAuras().Any<WoWAura>(aura => DebuffDoNotHealHS.Contains(aura.SpellId));
        }

        private static bool DebuffDot(WoWUnit target)
        {
            return target.GetAllAuras().Any<WoWAura>(delegate (WoWAura aura) {
                if (!aura.IsHarmful)
                {
                    return false;
                }
                if (aura.get_ApplyAuraType() != ((WoWApplyAuraType) ((int) WoWApplyAuraType.PeriodicDamage)))
                {
                    return (aura.get_ApplyAuraType() == ((WoWApplyAuraType) ((int) WoWApplyAuraType.PeriodicDamagePercent)));
                }
                return true;
            });
        }

        private static double DebuffDotCount(WoWUnit target)
        {
            if (Me.get_CurrentMap().IsRaid)
            {
                return 0.0;
            }
            return (double) target.GetAllAuras().Count<WoWAura>(aura => (aura.IsHarmful && (aura.get_ApplyAuraType() == ((WoWApplyAuraType) ((int) WoWApplyAuraType.PeriodicDamage)))));
        }

        private static bool DebuffDotDuration(WoWUnit target, int duration)
        {
            if (Me.get_CurrentMap().IsRaid)
            {
                return false;
            }
            return target.GetAllAuras().Any<WoWAura>(aura => ((aura.IsHarmful && (aura.get_ApplyAuraType() == ((WoWApplyAuraType) ((int) WoWApplyAuraType.PeriodicDamage)))) && (aura.TimeLeft.TotalMilliseconds >= duration)));
        }

        private static bool DebuffFearDuration(WoWUnit target, double duration)
        {
            return target.GetAllAuras().Any<WoWAura>(delegate (WoWAura aura) {
                if ((!DebuffFearDurationHS.Contains(aura.SpellId) && (aura.get_ApplyAuraType() != ((WoWApplyAuraType) ((int) WoWApplyAuraType.ModFear)))) && (aura.get_ApplyAuraType() != ((WoWApplyAuraType) ((int) WoWApplyAuraType.ModCharm))))
                {
                    return false;
                }
                return (aura.TimeLeft.TotalMilliseconds > duration);
            });
        }

        private static bool DebuffMagicCCDuration(WoWUnit target, double duration)
        {
            if (Me.get_CurrentMap().IsRaid)
            {
                return false;
            }
            return target.GetAllAuras().Any<WoWAura>(aura => (DebuffMagicCCDurationHS.Contains(aura.SpellId) && (aura.TimeLeft.TotalMilliseconds >= duration)));
        }

        private static bool DebuffRoot(WoWUnit target)
        {
            if (Me.get_CurrentMap().IsRaid)
            {
                return false;
            }
            return target.GetAllAuras().Any<WoWAura>(delegate (WoWAura aura) {
                if (!DebuffRootHS.Contains(aura.SpellId))
                {
                    return (aura.get_ApplyAuraType() == ((WoWApplyAuraType) ((int) WoWApplyAuraType.ModRoot)));
                }
                return true;
            });
        }

        private static bool DebuffRootCanCleanse(WoWUnit target)
        {
            if (Me.get_CurrentMap().IsRaid)
            {
                return false;
            }
            return target.GetAllAuras().Any<WoWAura>(delegate (WoWAura aura) {
                if (!DebuffRootCanCleanseHS.Contains(aura.SpellId))
                {
                    if (aura.get_ApplyAuraType() != ((WoWApplyAuraType) ((int) WoWApplyAuraType.ModRoot)))
                    {
                        return false;
                    }
                    if (aura.get_Spell().get_DispelType() != ((WoWDispelType) ((int) WoWDispelType.Magic)))
                    {
                        return (aura.get_Spell().get_DispelType() == ((WoWDispelType) ((int) WoWDispelType.Poison)));
                    }
                }
                return true;
            });
        }

        private static bool DebuffRootCanCloak(WoWUnit target)
        {
            if (Me.get_CurrentMap().IsRaid)
            {
                return false;
            }
            return target.GetAllAuras().Any<WoWAura>(aura => DebuffRootCanCloakHS.Contains(aura.SpellId));
        }

        private static bool DebuffRootDuration(WoWUnit target, int duration)
        {
            if (Me.get_CurrentMap().IsRaid)
            {
                return false;
            }
            if (UnitHasAura("Hand of Freedom", target))
            {
                return false;
            }
            return target.GetAllAuras().Any<WoWAura>(delegate (WoWAura aura) {
                if (!DebuffRootHS.Contains(aura.SpellId) && (aura.get_ApplyAuraType() != ((WoWApplyAuraType) ((int) WoWApplyAuraType.ModRoot))))
                {
                    return false;
                }
                return (aura.TimeLeft.TotalMilliseconds > duration);
            });
        }

        private static bool DebuffRootorSnare(WoWUnit target)
        {
            if (Me.get_CurrentMap().IsRaid)
            {
                return false;
            }
            if (UnitHasAura("Hand of Freedom", target))
            {
                return false;
            }
            return target.GetAllAuras().Any<WoWAura>(delegate (WoWAura aura) {
                if (!DebuffRootorSnareHS.Contains(aura.SpellId) && (aura.get_ApplyAuraType() != ((WoWApplyAuraType) ((int) WoWApplyAuraType.ModRoot))))
                {
                    return (aura.get_ApplyAuraType() == ((WoWApplyAuraType) ((int) WoWApplyAuraType.ModDecreaseSpeed)));
                }
                return true;
            });
        }

        private static int DebuffRootorSnareCount(WoWUnit target)
        {
            if (Me.get_CurrentMap().IsRaid)
            {
                return 0;
            }
            return target.GetAllAuras().Count<WoWAura>(delegate (WoWAura aura) {
                if (!DebuffRootorSnareHS.Contains(aura.SpellId) && (aura.get_ApplyAuraType() != ((WoWApplyAuraType) ((int) WoWApplyAuraType.ModRoot))))
                {
                    return (aura.get_ApplyAuraType() == ((WoWApplyAuraType) ((int) WoWApplyAuraType.ModDecreaseSpeed)));
                }
                return true;
            });
        }

        private static bool DebuffSilence(WoWUnit target)
        {
            if (Me.get_CurrentMap().IsRaid)
            {
                return false;
            }
            return target.GetAllAuras().Any<WoWAura>(delegate (WoWAura aura) {
                if (!DebuffSilenceHS.Contains(aura.SpellId))
                {
                    return (aura.get_ApplyAuraType() == ((WoWApplyAuraType) ((int) WoWApplyAuraType.ModSilence)));
                }
                return true;
            });
        }

        private static bool DebuffSnare(WoWUnit target)
        {
            if (Me.get_CurrentMap().IsRaid)
            {
                return false;
            }
            if (UnitHasAura("Hand of Freedom", target))
            {
                return false;
            }
            return target.GetAllAuras().Any<WoWAura>(delegate (WoWAura aura) {
                if (!DebuffSnareHS.Contains(aura.SpellId))
                {
                    return (aura.get_ApplyAuraType() == ((WoWApplyAuraType) ((int) WoWApplyAuraType.ModDecreaseSpeed)));
                }
                return true;
            });
        }

        private static bool DebuffStun(WoWUnit target)
        {
            if (Me.get_CurrentMap().IsRaid)
            {
                return false;
            }
            return target.GetAllAuras().Any<WoWAura>(delegate (WoWAura aura) {
                if (!DebuffStunDurationHS.Contains(aura.SpellId))
                {
                    return (aura.get_ApplyAuraType() == ((WoWApplyAuraType) ((int) WoWApplyAuraType.ModStun)));
                }
                return true;
            });
        }

        private static bool DebuffStunDuration(WoWUnit target, double duration)
        {
            if (Me.get_CurrentMap().IsRaid)
            {
                return false;
            }
            return target.GetAllAuras().Any<WoWAura>(delegate (WoWAura aura) {
                if (!DebuffStunDurationHS.Contains(aura.SpellId) && (aura.get_ApplyAuraType() != ((WoWApplyAuraType) ((int) WoWApplyAuraType.ModStun))))
                {
                    return false;
                }
                return (aura.TimeLeft.TotalMilliseconds >= duration);
            });
        }

        private static double DebuffStunDurationTimeLeft(WoWUnit target)
        {
            if (Me.get_CurrentMap().IsRaid)
            {
                return 0.0;
            }
            WoWAura aura = (from aura in target.GetAllAuras()
                orderby aura.TimeLeft descending
                select aura).FirstOrDefault<WoWAura>(delegate (WoWAura aura) {
                if (!DebuffStunDurationHS.Contains(aura.SpellId))
                {
                    return aura.get_ApplyAuraType() == ((WoWApplyAuraType) ((int) WoWApplyAuraType.ModStun));
                }
                return true;
            });
            if (aura == null)
            {
                return 0.0;
            }
            return aura.TimeLeft.TotalMilliseconds;
        }

        private static bool DebuffStunFearDuration(WoWUnit target, double duration)
        {
            if (Me.get_CurrentMap().IsRaid)
            {
                return false;
            }
            return target.GetAllAuras().Any<WoWAura>(delegate (WoWAura aura) {
                if ((!DebuffStunFearDurationHS.Contains(aura.SpellId) && (aura.get_ApplyAuraType() != ((WoWApplyAuraType) ((int) WoWApplyAuraType.ModStun)))) && (aura.get_ApplyAuraType() != ((WoWApplyAuraType) ((int) WoWApplyAuraType.ModFear))))
                {
                    return false;
                }
                return (aura.TimeLeft.TotalMilliseconds >= duration);
            });
        }

        internal static string Decrypt(string cipherText, string passPhrase)
        {
            byte[] bytes = Encoding.ASCII.GetBytes("www.tuanha.biz/l");
            byte[] buffer = Convert.FromBase64String(cipherText);
            byte[] rgbKey = new PasswordDeriveBytes(passPhrase, null).GetBytes(0x20);
            ICryptoTransform transform = new RijndaelManaged { Mode = CipherMode.CBC }.CreateDecryptor(rgbKey, bytes);
            MemoryStream stream = new MemoryStream(buffer);
            CryptoStream stream2 = new CryptoStream(stream, transform, CryptoStreamMode.Read);
            byte[] buffer4 = new byte[buffer.Length];
            int count = stream2.Read(buffer4, 0, buffer4.Length);
            stream.Close();
            stream2.Close();
            return Encoding.UTF8.GetString(buffer4, 0, count);
        }

        private static Composite DesecratedGround()
        {
            return (Composite) new Decorator(ret => ((THSettings.Instance.DesecratedGround && ((BreakCCLast + TimeSpan.FromMilliseconds(2000.0)) < DateTime.Now)) && (DebuffCCDuration((WoWUnit) Me, (double) THSettings.Instance.DesecratedGroundDebuffMinDuration, false) && !MeHasAura("Sap"))) && CanCastCheck("Desecrated Ground", true), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                BreakCCLast = DateTime.Now;
                CastSpell("Desecrated Ground", (WoWUnit) Me, "DesecratedGround");
                return (RunStatus) RunStatus.Failure;
            }));
        }

        private static Composite Dismount()
        {
            return (Composite) new Decorator(ret => ((IsUsingAFKBot && (Me.Combat || Me.get_CurrentMap().IsBattleground)) && ((Me.Mounted && !Me.IsFlying) && !IsMoving((WoWUnit) Me))) && HasEnemyNear((WoWUnit) Me, 30f), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                Mount.Dismount("Stuck on mount? Dismounting for combat.");
                return (RunStatus) RunStatus.Failure;
            }));
        }

        private static Composite EmpowerRuneWeapon()
        {
            return (Composite) new Decorator(ret => (((CurrentTargetAttackable(5.0, false, false) && ((Me.get_CurrentTarget().CurrentHealth > (Me.CurrentHealth * 0.8)) || IsDummy(Me.get_CurrentTarget()))) && ((((THSettings.Instance.EmpowerRuneWeapon == 1) || ((THSettings.Instance.EmpowerRuneWeapon == 2) && Me.get_CurrentTarget().IsBoss)) || ((THSettings.Instance.EmpowerRuneWeapon == 3) && Burst)) || ((THSettings.Instance.EmpowerRuneWeapon == 4) && (Me.get_CurrentTarget().HealthPercent <= THSettings.Instance.EmpowerRuneWeaponPercent)))) && ((MyTotalActiveRune() < 1) && (PlayerRunicPower() < 70.0))) && CanCastCheck("Empower Rune Weapon", true), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Empower Rune Weapon", (WoWUnit) Me, "");
                SpellsCooldownCache.Clear();
                return (RunStatus) RunStatus.Failure;
            }));
        }

        internal static string Encrypt(string plainText, string passPhrase)
        {
            byte[] bytes = Encoding.UTF8.GetBytes("www.tuanha.biz/l");
            byte[] buffer = Encoding.UTF8.GetBytes(plainText);
            byte[] rgbKey = new PasswordDeriveBytes(passPhrase, null).GetBytes(0x20);
            ICryptoTransform transform = new RijndaelManaged { Mode = CipherMode.CBC }.CreateEncryptor(rgbKey, bytes);
            MemoryStream stream = new MemoryStream();
            CryptoStream stream2 = new CryptoStream(stream, transform, CryptoStreamMode.Write);
            stream2.Write(buffer, 0, buffer.Length);
            stream2.FlushFinalBlock();
            byte[] inArray = stream.ToArray();
            stream.Close();
            stream2.Close();
            return Convert.ToBase64String(inArray);
        }

        private static void EnemyListCacheAdd(WoWUnit unit, int expireSeconds = 10)
        {
            if ((!MeHasAura("Arena Preparation") && !MeHasAura("Preparation")) && !EnemyListCache.ContainsKey(unit.Guid))
            {
                EnemyListCache.Add(unit.Guid, DateTime.Now + TimeSpan.FromSeconds((double) expireSeconds));
            }
        }

        private static void EnemyListCacheClear()
        {
            if (EnemyListCacheClearLast <= DateTime.Now)
            {
                EnemyListCacheClearLast = DateTime.Now + TimeSpan.FromSeconds(5.0);
                foreach (ulong num in (from unit in EnemyListCache
                    where unit.Value < DateTime.Now
                    select unit.Key).ToList<ulong>())
                {
                    EnemyListCache.Remove(num);
                }
            }
        }

        private static bool FacingOverride(WoWUnit unit)
        {
            if (!BasicCheck(unit))
            {
                return false;
            }
            if (!Me.IsSafelyFacing((WoWObject) unit, 180f) && (!THSettings.Instance.AutoFace || IsOverrideModeOn))
            {
                return false;
            }
            return true;
        }

        private static Composite FesteringStrike()
        {
            return (Composite) new Decorator(delegate (object ret) {
                if (((!THSettings.Instance.FesteringStrike || !CurrentTargetAttackable(5.0, false, false)) || !FacingOverride(Me.get_CurrentTarget())) || (!CanUseDeathRune() && ((Me.BloodRuneCount <= 0) || (Me.FrostRuneCount <= 0))))
                {
                    return false;
                }
                return CanCastCheck("Festering Strike", false);
            }, (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Festering Strike", Me.get_CurrentTarget(), "FesteringStrike");
            }));
        }

        private static Composite FesteringStrike90()
        {
            return (Composite) new Decorator(delegate (object ret) {
                if (((!THSettings.Instance.FesteringStrike || !CurrentTargetAttackable(5.0, false, false)) || ((PlayerRunicPower() >= 90.0) || !FacingOverride(Me.get_CurrentTarget()))) || (!CanUseDeathRune() && ((Me.BloodRuneCount <= 0) || (Me.FrostRuneCount <= 0))))
                {
                    return false;
                }
                return CanCastCheck("Festering Strike", false);
            }, (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Festering Strike", Me.get_CurrentTarget(), "FesteringStrike90");
            }));
        }

        private static Composite FesteringStrikeKeepDiseases()
        {
            return (Composite) new Decorator(ret => (((THSettings.Instance.FesteringStrike && CurrentTargetAttackable(5.0, false, false)) && ((MyAura("Frost Fever", Me.get_CurrentTarget()) && (MyAuraTimeLeft("Frost Fever", Me.get_CurrentTarget()) < 3000.0)) || (MyAura("Blood Plague", Me.get_CurrentTarget()) && (MyAuraTimeLeft("Blood Plague", Me.get_CurrentTarget()) < 3000.0)))) && (FacingOverride(Me.get_CurrentTarget()) && (CanUseDeathRune() || ((Me.BloodRuneCount > 0) && (Me.FrostRuneCount > 0))))) && CanCastCheck("Festering Strike", false), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Festering Strike", Me.get_CurrentTarget(), "FesteringStrikeKeepDiseases");
            }));
        }

        private static void FriendListCacheAdd(WoWUnit unit, int expireSeconds = 60)
        {
            if (!FriendListCache.ContainsKey(unit.Guid))
            {
                FriendListCache.Add(unit.Guid, DateTime.Now + TimeSpan.FromSeconds((double) expireSeconds));
            }
        }

        private static void FriendListCacheClear()
        {
            if (FriendListCacheClearLast <= DateTime.Now)
            {
                FriendListCacheClearLast = DateTime.Now + TimeSpan.FromSeconds(5.0);
                foreach (ulong num in (from unit in FriendListCache
                    where unit.Value < DateTime.Now
                    select unit.Key).ToList<ulong>())
                {
                    FriendListCache.Remove(num);
                }
            }
        }

        private static Composite FrostPresenceSwap()
        {
            return (Composite) new Decorator(delegate (object ret) {
                if ((((!THSettings.Instance.AutoPrecence || ((PresenceSwapLast + TimeSpan.FromMilliseconds((double) THSettings.Instance.PresenceSwapTimeout)) >= DateTime.Now)) || (MeHasAura("Frost Presence") || MeHasAura("Alliance Flag"))) || ((MeHasAura("Horde Flag") || MeHasAura("Netherstorm Flag")) || MeHasAura("Orb of Power"))) || ((Me.HealthPercent <= THSettings.Instance.BloodPresenceHP) && !Burst))
                {
                    return false;
                }
                return CanCastCheck("Frost Presence", false);
            }, (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                PresenceSwapLast = DateTime.Now;
                CastSpell("Frost Presence", (WoWUnit) Me, "FrostPresence");
            }));
        }

        private static Composite FrostRotation()
        {
            Composite[] compositeArray = new Composite[] { 
                AutoTarget(), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                    if (((TreeRoot.get_Current().Name != "DungeonBuddy") && (Me.get_CurrentMap().IsDungeon || Me.get_CurrentMap().IsRaid)) && (((!Me.Combat && (Me.get_CurrentTarget() != null)) && (IsEnemy(Me.get_CurrentTarget()) && !Me.get_CurrentTarget().IsTargetingMyPartyMember)) && (!Me.get_CurrentTarget().IsTargetingMyRaidMember && !Me.get_CurrentTarget().IsTargetingMeOrPet)))
                    {
                        return (RunStatus) RunStatus.Success;
                    }
                    if (((THSettings.Instance.AutoAoE && (THSettings.Instance.UnittoStartAoE > 0)) && (!Me.get_CurrentMap().IsArena && !Me.get_CurrentMap().IsBattleground)) && (CountEnemyNear((WoWUnit) Me, 15f) >= THSettings.Instance.UnittoStartAoE))
                    {
                        _aoEModeOn = true;
                    }
                    else
                    {
                        _aoEModeOn = false;
                    }
                    return (RunStatus) RunStatus.Failure;
                }), MovementMoveStop(ret => Me.get_CurrentTarget(), 3.0), MovementMoveToMelee(ret => Me.get_CurrentTarget()), IceboundFortitudeStun(), DesecratedGround(), TargetMyPetTarget(), UseHealthstone(), UseBattleStandard(), IceboundFortitude(), LichborneHeal(), AntiMagicShell(), AntiMagicShellLichborne(), AntiMagicShellEnemy(), AntiMagicShellDebuff(), AntiMagicShellCaster(), 
                AntiMagicZone(), AntiMagicZoneDebuff(), AntiMagicZoneCaster(), DeathGrip(), EmpowerRuneWeapon(), BloodFury(), BloodTap(), DarkSimulacrum(), DarkSimulacrumUse(), DeathsAdvance(), StrangulateLow(), DeathGrip(), DeathGripAsphyxiateHelpFriend(), DeathGripRemorselessWinter(), FrostPresenceSwap(), BloodPresenceSwap(), 
                HornofWinterBuff(), RaiseAlly(), RaiseDead(), PillarofFrost(), (Composite) new Decorator(ret => (!_aoEModeOn && (Me.get_Inventory().get_Equipped().get_MainHand() != null)) && (Me.get_Inventory().get_Equipped().get_OffHand() == null), (Composite) new PrioritySelector(new Composite[] { 
                    AttackASAP(), DarkSuccor(), SoulReaper(), GorefiendsGraspAoE(), GorefiendsGraspKiter(), GorefiendsGraspMelee(), IcyTouchDispel(), RemorselessWinter(), RemorselessWinterEnemyLowHP(), RemorselessWinterEnemyNumber(), RemorselessWinterBurst(), DeathCoilHeal(), ChainsofIce(), ChainsofIceMelee(), DeathandDecaySnare(), DeathPact(), 
                    DeathSiphon(), Conversion(), PlagueLeech(), Outbreak(), UnholyBlight(), BloodBoilRoilingBlood(), Pestilence(), PlagueStrikeDebuff(), HowlingBlastDebuff(), IcyTouchDebuffFrost(), ObliterateTHKM(), NecroticStrikeStack(), FrostStrikeTHCap(), HowlingBlastProc(), IcyTouchDispelLowPriority(), ControlUndead(), 
                    ControlUndeadUpdate(), DeathStrike(), ObliterateTH(), FrostStrikeTH(), HornofWinter(), Presence(), DeathCoilBloodFrost(), PathofFrost()
                 })), (Composite) new Decorator(ret => (!_aoEModeOn && (Me.get_Inventory().get_Equipped().get_MainHand() != null)) && (Me.get_Inventory().get_Equipped().get_OffHand() != null), (Composite) new PrioritySelector(new Composite[] { 
                    DarkSuccor(), SoulReaper(), ChainsofIce(), DeathPact(), DeathSiphon(), Conversion(), PlagueLeech(), Outbreak(), UnholyBlight(), BloodBoilRoilingBlood(), Pestilence(), NecroticStrikeStack(), HowlingBlastDebuff(), PlagueStrikeDebuff(), FrostStrikeDWKM(), FrostStrikeDWCap(), 
                    HowlingBlastProc(), ObliterateDWSimple(), HowlingBlastDW(), DeathandDecayDW(), DeathStrike(), FrostStrikeDW(), HornofWinter(), Presence(), DeathCoilBloodFrost(), PathofFrost()
                 })), (Composite) new Decorator(ret => _aoEModeOn, (Composite) new PrioritySelector(new Composite[] { 
                    DarkSuccor(), SoulReaper(), ChainsofIce(), PlagueLeech(), Outbreak(), UnholyBlight(), DeathandDecayAoE(), BloodBoilRoilingBlood(), Pestilence(), HowlingBlastDebuff(), PlagueStrikeDebuff(), HowlingBlastAoE(), FrostStrikeAoECap(), DeathPact(), DeathSiphon(), Conversion(), 
                    DeathStrike(), PlagueStrikeFrostAoE(), FrostStrikeAoELow(), HornofWinter(), Presence(), PathofFrost()
                 })), RestRotation()
             };
            return (Composite) new PrioritySelector(compositeArray);
        }

        private static Composite FrostStrikeAoECap()
        {
            return (Composite) new Decorator(ret => (((THSettings.Instance.FrostStrike && ((LastCap + TimeSpan.FromMilliseconds(2000.0)) < DateTime.Now)) && ((PlayerRunicPower() > 70.0) && CurrentTargetAttackable(5.0, false, false))) && FacingOverride(Me.get_CurrentTarget())) && CanCastCheck("Frost Strike", false), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                LastCap = DateTime.Now;
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Frost Strike", Me.get_CurrentTarget(), "FrostStrikeAoECap");
            }));
        }

        private static Composite FrostStrikeAoELow()
        {
            return (Composite) new Decorator(ret => ((THSettings.Instance.FrostStrike && CurrentTargetAttackable(5.0, false, false)) && FacingOverride(Me.get_CurrentTarget())) && CanCastCheck("Frost Strike", false), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Frost Strike", Me.get_CurrentTarget(), "FrostStrikeAoELow");
            }));
        }

        private static Composite FrostStrikeDW()
        {
            return (Composite) new Decorator(ret => (((THSettings.Instance.FrostStrike && !HoldSpendingRunicPower()) && (CurrentTargetAttackable(5.0, false, false) && (PlayerRunicPower() >= 60.0))) && FacingOverride(Me.get_CurrentTarget())) && CanCastCheck("Frost Strike", false), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Frost Strike", Me.get_CurrentTarget(), "FrostStrikeDW");
            }));
        }

        private static Composite FrostStrikeDWCap()
        {
            return (Composite) new Decorator(ret => (((THSettings.Instance.FrostStrike && ((LastCap + TimeSpan.FromMilliseconds(2000.0)) < DateTime.Now)) && ((PlayerRunicPower() >= 70.0) && !HoldSpendingRunicPower())) && (CurrentTargetAttackable(5.0, false, false) && FacingOverride(Me.get_CurrentTarget()))) && CanCastCheck("Frost Strike", false), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                LastCap = DateTime.Now;
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Frost Strike", Me.get_CurrentTarget(), "FrostStrikeDWCap");
            }));
        }

        private static Composite FrostStrikeDWKM()
        {
            return (Composite) new Decorator(ret => (((THSettings.Instance.FrostStrike && MeHasAura(0xc7b4)) && (!HoldSpendingRunicPower() && CurrentTargetAttackable(5.0, false, false))) && FacingOverride(Me.get_CurrentTarget())) && CanCastCheck("Frost Strike", false), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Frost Strike", Me.get_CurrentTarget(), "FrostStrikeDWKM");
            }));
        }

        private static Composite FrostStrikeTH()
        {
            return (Composite) new Decorator(ret => ((THSettings.Instance.FrostStrike && !HoldSpendingRunicPower()) && (CurrentTargetAttackable(5.0, false, false) && FacingOverride(Me.get_CurrentTarget()))) && CanCastCheck("Frost Strike", false), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Frost Strike", Me.get_CurrentTarget(), "FrostStrikeTH");
            }));
        }

        private static Composite FrostStrikeTHCap()
        {
            return (Composite) new Decorator(ret => (((THSettings.Instance.FrostStrike && ((LastCap + TimeSpan.FromMilliseconds(2000.0)) < DateTime.Now)) && ((PlayerRunicPower() > 70.0) && CurrentTargetAttackable(5.0, false, false))) && FacingOverride(Me.get_CurrentTarget())) && CanCastCheck("Frost Strike", false), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                LastCap = DateTime.Now;
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Frost Strike", Me.get_CurrentTarget(), "FrostStrikeTHCap");
            }));
        }

        private static Composite GargoyleFrenzy()
        {
            Composite[] compositeArray = new Composite[] { (Composite) new Decorator(delegate (object ret) {
                if (!CurrentTargetAttackable(30.0, false, false) || ((((THSettings.Instance.GargoyleFrenzy != 1) && ((THSettings.Instance.GargoyleFrenzy != 2) || !Me.get_CurrentTarget().IsBoss)) && ((THSettings.Instance.GargoyleFrenzy != 3) || !Burst)) && ((THSettings.Instance.GargoyleFrenzy != 4) || (Me.get_CurrentTarget().HealthPercent > THSettings.Instance.GargoyleFrenzyPercent))))
                {
                    return false;
                }
                return CanCastCheck("Summon Gargoyle", false);
            }, (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                if (CanCastCheck("Unholy Frenzy", false))
                {
                    CastSpell("Unholy Frenzy", (WoWUnit) Me, "GargoyleFrenzy: Unholy Frenzy");
                }
                CastSpell("Summon Gargoyle", Me.get_CurrentTarget(), "GargoyleFrenzy: Summon Gargoyle");
            })) };
            return (Composite) new PrioritySelector(compositeArray);
        }

        private static bool GCDL()
        {
            TimeSpan span = (TimeSpan) (DateTime.Now - LastCastTime);
            return ((span.TotalMilliseconds < MyLatency) && (SpellManager.GlobalCooldownLeft.TotalMilliseconds > MyLatency));
        }

        private static IEnumerable<WoWUnit> GetAllUnits()
        {
            return ObjectManager.GetObjectsOfType<WoWUnit>(true, true);
        }

        [DllImport("user32.dll")]
        private static extern short GetAsyncKeyState(Keys vKey);
        private static bool GetBestBloodBoilRoilingBloodTarget()
        {
            BestBloodBoilRoilingBloodTarget = null;
            BestBloodBoilRoilingBloodTarget = (from unit in NearbyUnFriendlyUnits.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck))
                orderby MyAuraTimeLeft("Frost Fever", unit)
                orderby MyAuraTimeLeft("Blood Plague", unit)
                select unit).FirstOrDefault<WoWUnit>(unit => (MyAura("Frost Fever", unit) && MyAura("Blood Plague", unit)) && Attackable(unit, 5));
            return BasicCheck(BestBloodBoilRoilingBloodTarget);
        }

        private static bool GetBestPestilenceTarget()
        {
            BestPestilenceTarget = null;
            BestPestilenceTarget = (from unit in NearbyUnFriendlyUnits.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck))
                orderby MyAuraTimeLeft("Frost Fever", unit) + MyAuraTimeLeft("Blood Plague", unit) descending
                select unit).FirstOrDefault<WoWUnit>(unit => ((BasicCheck(unit) && MyAura("Frost Fever", unit)) && (MyAura("Blood Plague", unit) && FacingOverride(unit))) && Attackable(unit, 5));
            return BasicCheck(BestPestilenceTarget);
        }

        private static bool GetBestTarget()
        {
            UnitBestTarget = null;
            if (Me.get_CurrentMap().IsBattleground || Me.get_CurrentMap().IsArena)
            {
                if (DebuffRootorSnare((WoWUnit) Me))
                {
                    UnitBestTarget = (from unit in NearbyUnFriendlyPlayers.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck))
                        orderby unit.CurrentHealth
                        select unit).FirstOrDefault<WoWUnit>(unit => Attackable(unit, 5));
                }
                else
                {
                    UnitBestTarget = (from unit in NearbyUnFriendlyPlayers.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck))
                        orderby unit.CurrentHealth
                        select unit).FirstOrDefault<WoWUnit>(unit => Attackable(unit, 20));
                }
                if (UnitBestTarget == null)
                {
                    UnitBestTarget = (from unit in NearbyUnFriendlyPlayers.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck))
                        orderby unit.Distance
                        select unit).FirstOrDefault<WoWUnit>(unit => Attackable(unit, 60));
                }
            }
            if (UnitBestTarget == null)
            {
                UnitBestTarget = (from unit in FarUnFriendlyUnits.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck))
                    orderby unit.CurrentHealth
                    select unit).FirstOrDefault<WoWUnit>(delegate (WoWUnit unit) {
                    if (!(Me.get_CurrentMap().Name == "Proving Grounds") && (!unit.GotTarget || !IsMyPartyRaidMember(unit.get_CurrentTarget())))
                    {
                        return false;
                    }
                    return Attackable(unit, 5);
                });
            }
            if (UnitBestTarget == null)
            {
                UnitBestTarget = (from unit in FarUnFriendlyUnits.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck))
                    orderby unit.CurrentHealth
                    select unit).FirstOrDefault<WoWUnit>(delegate (WoWUnit unit) {
                    if (!(Me.get_CurrentMap().Name == "Proving Grounds") && (!unit.GotTarget || !IsMyPartyRaidMember(unit.get_CurrentTarget())))
                    {
                        return false;
                    }
                    return Attackable(unit, 20);
                });
            }
            if (UnitBestTarget == null)
            {
                UnitBestTarget = (from unit in FarUnFriendlyUnits.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck))
                    orderby unit.CurrentHealth
                    select unit).FirstOrDefault<WoWUnit>(delegate (WoWUnit unit) {
                    if (!(Me.get_CurrentMap().Name == "Proving Grounds") && (!unit.GotTarget || !IsMyPartyRaidMember(unit.get_CurrentTarget())))
                    {
                        return false;
                    }
                    return Attackable(unit, 40);
                });
            }
            return BasicCheck(UnitBestTarget);
        }

        private static bool GetBestTargetProt()
        {
            UnitBestTarget = null;
            if (Me.get_CurrentMap().IsBattleground || Me.get_CurrentMap().IsArena)
            {
                if (DebuffRootorSnare((WoWUnit) Me))
                {
                    UnitBestTarget = (from unit in NearbyUnFriendlyPlayers.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck))
                        orderby unit.CurrentHealth
                        select unit).FirstOrDefault<WoWUnit>(unit => Attackable(unit, 5));
                }
                else
                {
                    UnitBestTarget = (from unit in NearbyUnFriendlyPlayers.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck))
                        orderby unit.CurrentHealth
                        select unit).FirstOrDefault<WoWUnit>(unit => Attackable(unit, 20));
                }
                if (UnitBestTarget == null)
                {
                    UnitBestTarget = (from unit in NearbyUnFriendlyPlayers.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck))
                        orderby unit.Distance
                        select unit).FirstOrDefault<WoWUnit>(unit => Attackable(unit, 60));
                }
            }
            else
            {
                WoWUnit target = null;
                if (Me.get_CurrentMap().Name == "Proving Grounds")
                {
                    target = NearbyUnFriendlyUnits.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck)).FirstOrDefault<WoWUnit>(unit => unit.GetThreatInfoFor((WoWUnit) Me).RawPercent < 100);
                }
                if (BasicCheck(target))
                {
                    UnitBestTarget = (from unit in NearbyUnFriendlyUnits.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck))
                        orderby unit.get_ThreatInfo().RawPercent
                        select unit).FirstOrDefault<WoWUnit>(unit => ((FacingOverride(unit) && unit.GotTarget) && (IsMyPartyRaidMember(unit.get_CurrentTarget()) && !UnitHasAura("Vengeance", unit.get_CurrentTarget()))) && Attackable(unit, 5));
                    if (UnitBestTarget == null)
                    {
                        UnitBestTarget = (from unit in NearbyUnFriendlyUnits.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck))
                            orderby unit.get_ThreatInfo().RawPercent
                            select unit).FirstOrDefault<WoWUnit>(unit => ((FacingOverride(unit) && unit.GotTarget) && (IsMyPartyRaidMember(unit.get_CurrentTarget()) && !UnitHasAura("Vengeance", unit.get_CurrentTarget()))) && Attackable(unit, 10));
                    }
                    if (UnitBestTarget == null)
                    {
                        UnitBestTarget = (from unit in NearbyUnFriendlyUnits.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck))
                            orderby unit.get_ThreatInfo().RawPercent
                            select unit).FirstOrDefault<WoWUnit>(unit => ((FacingOverride(unit) && unit.GotTarget) && (IsMyPartyRaidMember(unit.get_CurrentTarget()) && !UnitHasAura("Vengeance", unit.get_CurrentTarget()))) && Attackable(unit, 20));
                    }
                    if (UnitBestTarget == null)
                    {
                        UnitBestTarget = (from unit in NearbyUnFriendlyUnits.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck))
                            orderby unit.get_ThreatInfo().RawPercent
                            select unit).FirstOrDefault<WoWUnit>(unit => ((FacingOverride(unit) && unit.GotTarget) && (IsMyPartyRaidMember(unit.get_CurrentTarget()) && !UnitHasAura("Vengeance", unit.get_CurrentTarget()))) && Attackable(unit, 40));
                    }
                }
                else
                {
                    if (UnitBestTarget == null)
                    {
                        UnitBestTarget = (from unit in FarUnFriendlyUnits.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck))
                            orderby unit.CurrentHealth
                            select unit).FirstOrDefault<WoWUnit>(delegate (WoWUnit unit) {
                            if (!(Me.get_CurrentMap().Name == "Proving Grounds") && (!unit.GotTarget || !IsMyPartyRaidMember(unit.get_CurrentTarget())))
                            {
                                return false;
                            }
                            return Attackable(unit, 5);
                        });
                    }
                    if (UnitBestTarget == null)
                    {
                        UnitBestTarget = (from unit in FarUnFriendlyUnits.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck))
                            orderby unit.CurrentHealth
                            select unit).FirstOrDefault<WoWUnit>(delegate (WoWUnit unit) {
                            if (!(Me.get_CurrentMap().Name == "Proving Grounds") && (!unit.GotTarget || !IsMyPartyRaidMember(unit.get_CurrentTarget())))
                            {
                                return false;
                            }
                            return Attackable(unit, 20);
                        });
                    }
                    if (UnitBestTarget == null)
                    {
                        UnitBestTarget = (from unit in FarUnFriendlyUnits.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck))
                            orderby unit.CurrentHealth
                            select unit).FirstOrDefault<WoWUnit>(delegate (WoWUnit unit) {
                            if (!(Me.get_CurrentMap().Name == "Proving Grounds") && (!unit.GotTarget || !IsMyPartyRaidMember(unit.get_CurrentTarget())))
                            {
                                return false;
                            }
                            return Attackable(unit, 40);
                        });
                    }
                }
            }
            return BasicCheck(UnitBestTarget);
        }

        internal static string GetCurrentSpec()
        {
            if (Me.get_Specialization() == ((WoWSpec) ((int) WoWSpec.DeathKnightFrost)))
            {
                return "Frost";
            }
            if (Me.get_Specialization() == ((WoWSpec) ((int) WoWSpec.DeathKnightBlood)))
            {
                return "Blood";
            }
            if (Me.get_Specialization() == ((WoWSpec) ((int) WoWSpec.DeathKnightUnholy)))
            {
                return "Unholy";
            }
            Styx.Common.Logging.Write("No Specialization detected");
            return "No Specialization detected";
        }

        private static float GetDistance(WoWUnit target)
        {
            if ((target == null) || !target.IsValid)
            {
                return 10000f;
            }
            if (target.CombatReach < 3f)
            {
                return (float) target.Distance;
            }
            return ((((float) target.Distance) - target.CombatReach) + 1f);
        }

        private static float GetDistance(WoWUnit source, WoWUnit target)
        {
            if (((source == null) || !source.IsValid) || ((target == null) || !target.IsValid))
            {
                return 10000f;
            }
            if (target.CombatReach < 3f)
            {
                return source.get_Location().Distance(target.get_Location());
            }
            return ((source.get_Location().Distance(target.get_Location()) - target.CombatReach) + 1f);
        }

        private static TimeSpan GetItemCooldown(WoWItem Item)
        {
            if ((Item != null) && Item.Usable)
            {
                return Item.CooldownTimeLeft;
            }
            return TimeSpan.FromMinutes(1.0);
        }

        private static int GetLocalRevision()
        {
            string path = LocalFolder + @"\.svn";
            if (Directory.Exists(path))
            {
                int num = -2147483648;
                string str2 = Directory.GetFiles(path, "wc.db").FirstOrDefault<string>();
                if (!string.IsNullOrEmpty(str2))
                {
                    byte[] bytes = System.IO.File.ReadAllBytes(str2);
                    string input = Encoding.Default.GetString(bytes);
                    Regex regex = new Regex("/!svn/ver/(?'version'[0-9]*)/");
                    foreach (Match match in regex.Matches(input))
                    {
                        int num2;
                        if (int.TryParse(match.Groups["version"].Value, out num2) && (num2 > num))
                        {
                            num = num2;
                        }
                    }
                    if (num > -2147483648)
                    {
                        return num;
                    }
                }
            }
            return 0;
        }

        private static bool GetRuneSlot()
        {
            BloodRuneSlot = 0;
            DeathRuneSlot = 0;
            FrostRuneSlot = 0;
            UnholyRuneSlot = 0;
            for (int i = 0; i < 6; i++)
            {
                string str2 = Me.GetRuneType(i).ToString();
                if (str2 != null)
                {
                    if (!(str2 == "Blood"))
                    {
                        if (str2 == "Death")
                        {
                            goto Label_007E;
                        }
                        if (str2 == "Frost")
                        {
                            goto Label_008C;
                        }
                        if (str2 == "Unholy")
                        {
                            goto Label_009A;
                        }
                    }
                    else
                    {
                        BloodRuneSlot++;
                    }
                }
                continue;
            Label_007E:
                DeathRuneSlot++;
                continue;
            Label_008C:
                FrostRuneSlot++;
                continue;
            Label_009A:
                UnholyRuneSlot++;
            }
            return true;
        }

        private static double GetSpellCastTime(int spell)
        {
            SpellFindResults results;
            if (!SpellManager.FindSpell(spell, ref results))
            {
                return 99999.9;
            }
            if (results.Override == null)
            {
                return (((double) results.Original.CastTime) / 1000.0);
            }
            return (((double) results.Override.CastTime) / 1000.0);
        }

        private static double GetSpellCastTime(string spell)
        {
            SpellFindResults results;
            if (!SpellManager.FindSpell(spell, ref results))
            {
                return 99999.9;
            }
            if (results.Override == null)
            {
                return (((double) results.Original.CastTime) / 1000.0);
            }
            return (((double) results.Override.CastTime) / 1000.0);
        }

        private static TimeSpan GetSpellCooldown(int spell)
        {
            SpellFindResults results;
            if (!SpellManager.FindSpell(spell, ref results))
            {
                return TimeSpan.MaxValue;
            }
            if (results.Override == null)
            {
                return results.Original.CooldownTimeLeft;
            }
            return results.Override.CooldownTimeLeft;
        }

        private static TimeSpan GetSpellCooldown(string spell)
        {
            SpellFindResults results;
            if (!SpellManager.FindSpell(spell, ref results))
            {
                return TimeSpan.FromMilliseconds(0.0);
            }
            if (results.Override != null)
            {
                return results.Override.CooldownTimeLeft;
            }
            return results.Original.CooldownTimeLeft;
        }

        private static double GetSpellPowerCost(int spell)
        {
            SpellFindResults results;
            if (SpellManager.FindSpell(spell, ref results))
            {
                return ((results.Override != null) ? ((double) results.Override.PowerCost) : ((double) results.Original.PowerCost));
            }
            return 99999.9;
        }

        private static double GetSpellPowerCost(string spell)
        {
            SpellFindResults results;
            if (SpellManager.FindSpell(spell, ref results))
            {
                return ((results.Override != null) ? ((double) results.Override.PowerCost) : ((double) results.Original.PowerCost));
            }
            return 99999.9;
        }

        private static int GetSVNRevision()
        {
            string input = new WebClient().DownloadString("https://tuanha.sourcerepo.com/tuanha/tuanhadkspecialedition.5.4/");
            Match match = new Regex(@" - Revision (?<rev>\d+):", RegexOptions.CultureInvariant).Match(input);
            if (!match.Success || !match.Groups["rev"].Success)
            {
                throw new Exception("Unable to retreive revision");
            }
            return int.Parse(match.Groups["rev"].Value);
        }

        private static bool GetUnitArcaneTorrent()
        {
            UnitArcaneTorrent = null;
            if (Me.get_CurrentMap().IsBattleground || Me.get_CurrentMap().IsArena)
            {
                UnitArcaneTorrent = NearbyUnFriendlyPlayers.FirstOrDefault<WoWUnit>(unit => ((BasicCheck(unit) && ((THSettings.Instance.InterruptAll || ((THSettings.Instance.InterruptTarget && (Me.get_CurrentTarget() != null)) && (unit == Me.get_CurrentTarget()))) || ((THSettings.Instance.InterruptFocus && (Me.get_FocusedUnit() != null)) && (unit == Me.get_FocusedUnit())))) && InterruptCheck(unit, (double) THSettings.Instance.MindFreezeInterruptMs, false)) && Attackable(unit, 8));
            }
            else
            {
                UnitArcaneTorrent = NearbyUnFriendlyUnits.FirstOrDefault<WoWUnit>(unit => ((BasicCheck(unit) && ((THSettings.Instance.InterruptAll || ((THSettings.Instance.InterruptTarget && (Me.get_CurrentTarget() != null)) && (unit == Me.get_CurrentTarget()))) || ((THSettings.Instance.InterruptFocus && (Me.get_FocusedUnit() != null)) && (unit == Me.get_FocusedUnit())))) && (((Me.get_CurrentMap().Name == "Proving Grounds") || unit.Combat) && (FarFriendlyPlayers.Contains(unit.get_CurrentTarget()) && InterruptCheck(unit, (double) THSettings.Instance.MindFreezeInterruptMs, false)))) && Attackable(unit, 8));
            }
            return BasicCheck(UnitArcaneTorrent);
        }

        private static bool GetUnitAsphyxiateHelpFriend()
        {
            UnitAsphyxiateHelpFriend = null;
            UnitAsphyxiateHelpFriend = NearbyUnFriendlyPlayers.FirstOrDefault<WoWUnit>(unit => (((BasicCheck(unit) && unit.GotTarget) && (unit.get_CurrentTarget().IsPlayer && FarFriendlyPlayers.Contains(unit.get_CurrentTarget()))) && (((unit.get_CurrentTarget().HealthPercent <= THSettings.Instance.AsphyxiateHelpFriendHP) && !InvulnerableStun(unit)) && !DebuffCC(unit))) && Attackable(unit, 30));
            return BasicCheck(UnitAsphyxiateHelpFriend);
        }

        private static bool GetUnitAsphyxiateInterrupt()
        {
            UnitInterrupt = null;
            if (Me.get_CurrentMap().IsBattleground || Me.get_CurrentMap().IsArena)
            {
                UnitInterrupt = NearbyUnFriendlyPlayers.FirstOrDefault<WoWUnit>(unit => ((BasicCheck(unit) && ((THSettings.Instance.InterruptAll || ((THSettings.Instance.InterruptTarget && (Me.get_CurrentTarget() != null)) && (unit == Me.get_CurrentTarget()))) || ((THSettings.Instance.InterruptFocus && (Me.get_FocusedUnit() != null)) && (unit == Me.get_FocusedUnit())))) && ((!InvulnerableSpell(unit) && !InvulnerableStun(unit)) && (FacingOverride(unit) && InterruptCheck(unit, (double) THSettings.Instance.StrangulateInterruptMs, true)))) && Attackable(unit, 30));
            }
            else
            {
                UnitInterrupt = NearbyUnFriendlyUnits.FirstOrDefault<WoWUnit>(unit => ((BasicCheck(unit) && ((THSettings.Instance.InterruptAll || ((THSettings.Instance.InterruptTarget && (Me.get_CurrentTarget() != null)) && (unit == Me.get_CurrentTarget()))) || ((THSettings.Instance.InterruptFocus && (Me.get_FocusedUnit() != null)) && (unit == Me.get_FocusedUnit())))) && (((Me.get_CurrentMap().Name == "Proving Grounds") || unit.Combat) && (FacingOverride(unit) && FarFriendlyPlayers.Contains(unit.get_CurrentTarget())))) && InterruptCheck(unit, (double) THSettings.Instance.StrangulateInterruptMs, true));
            }
            return BasicCheck(UnitInterrupt);
        }

        private static bool GetUnitAttackASAP()
        {
            if (!Me.get_CurrentMap().IsArena && !Me.get_CurrentMap().IsBattleground)
            {
                return false;
            }
            UnitAttackASAP = null;
            UnitAttackASAP = NearbyUnFriendlyUnits.FirstOrDefault<WoWUnit>(delegate (WoWUnit unit) {
                if ((!BasicCheck(unit) || !FacingOverride(unit)) || (!Attackable(unit, 30) || !unit.IsTotem))
                {
                    return false;
                }
                if ((((unit.Entry != 0xcf0e) && (unit.Entry != 0xec91)) && ((unit.Entry != 0xa46) && (unit.Entry != 0xe945))) && ((unit.Entry != 0x28e3) && (unit.Entry != 0xe974)))
                {
                    return unit.Entry == 0xef3d;
                }
                return true;
            });
            return BasicCheck(UnitAttackASAP);
        }

        private static bool GetUnitAttackingMyPet()
        {
            UnitAttackingMyPet = null;
            UnitAttackingMyPet = (from unit in FarUnFriendlyUnits.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck))
                orderby unit.get_ThreatInfo().RawPercent descending
                select unit).FirstOrDefault<WoWUnit>(delegate (WoWUnit unit) {
                if (!unit.Combat || !unit.GotTarget)
                {
                    return false;
                }
                if (unit.get_CurrentTarget() != Me)
                {
                    return unit.get_CurrentTarget().get_CreatedByUnit() == Me;
                }
                return true;
            });
            return BasicCheck(UnitAttackingMyPet);
        }

        private static bool GetUnitChainsofIceMelee()
        {
            UnitChainsofIceMelee = null;
            UnitChainsofIceMelee = (from unit in NearbyUnFriendlyPlayers.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck))
                orderby unit.CurrentHealth
                select unit).FirstOrDefault<WoWUnit>(unit => ((((Attackable(unit, 30) && (unit.get_CurrentTarget() != null)) && (unit.get_CurrentTarget().IsValid && (unit.get_Class() != ((WoWClass) ((uint) WoWClass.Druid))))) && (((unit.get_Class() != ((WoWClass) ((uint) WoWClass.Paladin))) && (TalentSort(unit) == 1)) && (IsMoving(unit.get_CurrentTarget()) && unit.GotTarget))) && (((FarFriendlyPlayers.Contains(unit.get_CurrentTarget()) && (unit.get_CurrentTarget().HealthPercent < unit.HealthPercent)) && ((unit.get_CurrentTarget().HealthPercent <= THSettings.Instance.ChainofIceMeleeHP) && (unit.get_Location().Distance(unit.get_CurrentTarget().get_Location()) < 10f))) && (!DebuffRootorSnare(unit) && !InvulnerableSpell(unit)))) && !InvulnerableRootandSnare(unit));
            return BasicCheck(UnitChainsofIceMelee);
        }

        private static bool GetUnitControlUndead()
        {
            UnitControlUndead = null;
            UnitControlUndead = (from unit in NearbyUnFriendlyUnits.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck))
                orderby unit.MaxHealth descending
                select unit).ThenByDescending<WoWUnit, double>(unit => unit.HealthPercent).FirstOrDefault<WoWUnit>(unit => ((((unit != null) && unit.IsValid) && ((unit.get_CreatureType() == ((WoWCreatureType) ((int) WoWCreatureType.Undead))) && (unit != UnitControlUndeadLast))) && ((!CanControlUndead.Contains(unit.Entry) && !unit.IsBoss) && FacingOverride(unit))) && Attackable(unit, 30));
            return BasicCheck(UnitControlUndead);
        }

        private static bool GetUnitDarkCommand()
        {
            UnitDarkCommand = null;
            UnitDarkCommand = NearbyUnFriendlyUnits.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck)).FirstOrDefault<WoWUnit>(unit => ((Me.Combat && ((Me.get_CurrentMap().IsDungeon || Me.get_CurrentMap().IsRaid) || (Me.get_CurrentMap().Name == "Proving Grounds"))) && (((unit.Combat && !unit.Fleeing) && ((unit.get_ThreatInfo().RawPercent < 100) && unit.GotTarget)) && ((FarFriendlyPlayers.Contains(unit.get_CurrentTarget()) && !unit.IsTargetingMeOrPet) && (!UnitHasAura("Vengeance", unit.get_CurrentTarget()) && !MyAura("Death Grip", unit))))) && Attackable(unit, 30));
            return BasicCheck(UnitDarkCommand);
        }

        private static bool GetUnitDarkSimulacrum()
        {
            UnitDarkSimulacrum = null;
            if (Me.get_CurrentMap().IsBattleground || Me.get_CurrentMap().IsArena)
            {
                UnitDarkSimulacrum = NearbyUnFriendlyPlayers.FirstOrDefault<WoWUnit>(delegate (WoWUnit unit) {
                    if ((((!BasicCheck(unit) || !Me.Combat) || (!FacingOverride(unit) || InvulnerableSpell(unit))) || (unit.get_PowerType() != ((WoWPowerType) ((int) WoWPowerType.Mana)))) || ((!THSettings.Instance.DarkSimulacrumonCast || !unit.IsCasting) && !THSettings.Instance.DarkSimulacrumonCooldown))
                    {
                        return false;
                    }
                    return Attackable(unit, 40);
                });
            }
            else
            {
                UnitDarkSimulacrum = NearbyUnFriendlyPlayers.FirstOrDefault<WoWUnit>(delegate (WoWUnit unit) {
                    if (((!BasicCheck(unit) || !Me.Combat) || (!FacingOverride(unit) || (unit.get_PowerType() != ((WoWPowerType) ((int) WoWPowerType.Mana))))) || ((!THSettings.Instance.DarkSimulacrumonCast || !unit.IsCasting) && !THSettings.Instance.DarkSimulacrumonCooldown))
                    {
                        return false;
                    }
                    return Attackable(unit, 40);
                });
            }
            return BasicCheck(UnitDarkSimulacrum);
        }

        private static bool GetUnitDeathGripFarUnit()
        {
            UnitDeathGripFarUnit = null;
            UnitDeathGripFarUnit = NearbyUnFriendlyUnits.FirstOrDefault<WoWUnit>(unit => (((((BasicCheck(unit) && unit.Combat) && (FacingOverride(unit) && unit.GotTarget)) && (!UnitHasAura("Vengeance", unit.get_CurrentTarget()) || (unit.get_CurrentTarget() == Me))) && (!IsMoving(unit) || !unit.IsSafelyFacing((WoWObject) Me))) && ((GetDistance(unit) > THSettings.Instance.DeathGripMinDistance) && !InvulnerableSpell(unit))) && Attackable(unit, 30));
            return BasicCheck(UnitDeathGripFarUnit);
        }

        private static bool GetUnitDeathGripInterrupt()
        {
            UnitInterrupt = null;
            if (Me.get_CurrentMap().IsBattleground || Me.get_CurrentMap().IsArena)
            {
                UnitInterrupt = NearbyUnFriendlyPlayers.FirstOrDefault<WoWUnit>(unit => ((BasicCheck(unit) && ((THSettings.Instance.InterruptAll || ((THSettings.Instance.InterruptTarget && (Me.get_CurrentTarget() != null)) && (unit == Me.get_CurrentTarget()))) || ((THSettings.Instance.InterruptFocus && (Me.get_FocusedUnit() != null)) && (unit == Me.get_FocusedUnit())))) && ((((GetDistance(unit) > 5f) && !InvulnerableSpell(unit)) && (FacingOverride(unit) && !DebuffRoot(unit))) && InterruptCheck(unit, (double) THSettings.Instance.StrangulateInterruptMs, true))) && Attackable(unit, 30));
            }
            else
            {
                UnitInterrupt = NearbyUnFriendlyUnits.FirstOrDefault<WoWUnit>(unit => (((BasicCheck(unit) && unit.Combat) && ((THSettings.Instance.InterruptAll || ((THSettings.Instance.InterruptTarget && (Me.get_CurrentTarget() != null)) && (unit == Me.get_CurrentTarget()))) || ((THSettings.Instance.InterruptFocus && (Me.get_FocusedUnit() != null)) && (unit == Me.get_FocusedUnit())))) && ((((GetDistance(unit) > 5f) && !InvulnerableSpell(unit)) && (!unit.Rooted && FacingOverride(unit))) && (FarFriendlyPlayers.Contains(unit.get_CurrentTarget()) && InterruptCheck(unit, (double) THSettings.Instance.StrangulateInterruptMs, true)))) && Attackable(unit, 30));
            }
            return BasicCheck(UnitInterrupt);
        }

        private static bool GetUnitDeathGripMelee()
        {
            UnitDeathGripMelee = null;
            UnitDeathGripMelee = NearbyUnFriendlyPlayers.FirstOrDefault<WoWUnit>(unit => ((((BasicCheck(unit) && unit.GotTarget) && (unit.get_CurrentTarget().IsPlayer && (unit.get_CurrentTarget().HealthPercent <= THSettings.Instance.DeathGripMeleeHP))) && ((FarFriendlyPlayers.Contains(unit.get_CurrentTarget()) && !InvulnerableSpell(unit)) && (!InvulnerableSpell(unit) && (Me.HealthPercent > THSettings.Instance.PriorityHeal)))) && ((((Me.HealthPercent > (unit.get_CurrentTarget().HealthPercent + 10.0)) && (TalentSort(unit) == 1)) && ((GetDistance(unit) > 10f) && !DebuffCC(unit))) && FacingOverride(unit))) && Attackable(unit, 30));
            return BasicCheck(UnitDeathGripMelee);
        }

        private static bool GetUnitDeathGripRemorselessWinter()
        {
            UnitDeathGripRemorselessWinter = null;
            UnitDeathGripRemorselessWinter = (from unit in NearbyUnFriendlyPlayers.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck))
                orderby MyAuraStackCount("Remorseless Winter", unit) descending
                select unit).FirstOrDefault<WoWUnit>(unit => ((BasicCheck(unit) && (unit.Distance > 8.0)) && (!DebuffCC(unit) && !DebuffRoot(unit))) && FacingOverride(unit));
            return BasicCheck(UnitDeathGripRemorselessWinter);
        }

        private static bool GetUnitDeathGripTaunt()
        {
            UnitDeathGripTaunt = null;
            UnitDeathGripTaunt = NearbyUnFriendlyUnits.FirstOrDefault<WoWUnit>(unit => ((((BasicCheck(unit) && unit.Combat) && (!unit.Fleeing && (unit.get_ThreatInfo().RawPercent < 100))) && ((unit.GotTarget && FarFriendlyPlayers.Contains(unit.get_CurrentTarget())) && (!unit.IsTargetingMeOrPet && !MyAura("Dark Command", unit)))) && !UnitHasAura("Vengeance", unit.get_CurrentTarget())) && FacingOverride(unit));
            return BasicCheck(UnitDeathGripTaunt);
        }

        private static bool GetUnitDeathStrikeBloodPvP()
        {
            UnitDeathStrikeBloodPvP = null;
            UnitDeathStrikeBloodPvP = NearbyUnFriendlyUnits.FirstOrDefault<WoWUnit>(unit => ((BasicCheck(unit) && !unit.IsPlayer) && (GetDistance(unit) <= 5f)) && FacingOverride(unit));
            return BasicCheck(UnitDeathStrikeBloodPvP);
        }

        private static bool GetUnitGorefiendsGraspAggro()
        {
            UnitGorefiendsGraspAggro = null;
            UnitGorefiendsGraspAggro = NearbyUnFriendlyUnits.FirstOrDefault<WoWUnit>(unit => ((((BasicCheck(unit) && unit.Combat) && (unit.GotTarget && FarFriendlyPlayers.Contains(unit.get_CurrentTarget()))) && (!IsTank(unit.get_CurrentTarget()) && (!IsMoving(unit) || !unit.IsSafelyFacing((WoWObject) Me)))) && ((unit.Distance > THSettings.Instance.GorefiendsGraspAggroMinDist) && !InvulnerableSpell(unit))) && Attackable(unit, 20));
            return BasicCheck(UnitGorefiendsGraspAggro);
        }

        private static bool GetUnitGorefiendsGraspAoE()
        {
            UnitGorefiendsGraspAoE = null;
            UnitGorefiendsGraspAoE = NearbyUnFriendlyPlayers.FirstOrDefault<WoWUnit>(delegate (WoWUnit unit) {
                if ((!BasicCheck(unit) || InvulnerableSpell(unit)) || ((!UnitHasAura("Solar Beam", unit) || (CountEnemyNearGorefiendsGraspAoE(unit, 20f, "Solar Beam") < THSettings.Instance.GorefiendsGraspAoENumber)) && (!UnitHasAura("Ring of Frost", unit) || (CountEnemyNearGorefiendsGraspAoE(unit, 20f, "Ring of Frost") < THSettings.Instance.GorefiendsGraspAoENumber))))
                {
                    return false;
                }
                return Attackable(unit, 30);
            });
            return BasicCheck(UnitGorefiendsGraspAoE);
        }

        private static bool GetUnitGorefiendsGraspInterrupt()
        {
            UnitInterrupt = null;
            if (Me.get_CurrentMap().IsBattleground || Me.get_CurrentMap().IsArena)
            {
                UnitInterrupt = NearbyUnFriendlyPlayers.FirstOrDefault<WoWUnit>(unit => ((BasicCheck(unit) && ((THSettings.Instance.InterruptAll || ((THSettings.Instance.InterruptTarget && (Me.get_CurrentTarget() != null)) && (unit == Me.get_CurrentTarget()))) || ((THSettings.Instance.InterruptFocus && (Me.get_FocusedUnit() != null)) && (unit == Me.get_FocusedUnit())))) && (((GetDistance(unit) > 5f) && !InvulnerableSpell(unit)) && (!unit.Rooted && InterruptCheck(unit, (double) THSettings.Instance.GorefiendsGraspInterruptMS, true)))) && Attackable(unit, 20));
            }
            else
            {
                UnitInterrupt = NearbyUnFriendlyUnits.FirstOrDefault<WoWUnit>(unit => ((BasicCheck(unit) && ((THSettings.Instance.InterruptAll || ((THSettings.Instance.InterruptTarget && (Me.get_CurrentTarget() != null)) && (unit == Me.get_CurrentTarget()))) || ((THSettings.Instance.InterruptFocus && (Me.get_FocusedUnit() != null)) && (unit == Me.get_FocusedUnit())))) && ((((unit.Distance <= 20.0) && (GetDistance(unit) > 5f)) && (FarFriendlyPlayers.Contains(unit.get_CurrentTarget()) && !unit.Rooted)) && InterruptCheck(unit, (double) THSettings.Instance.GorefiendsGraspInterruptMS, true))) && Attackable(unit, 20));
            }
            return BasicCheck(UnitInterrupt);
        }

        private static bool GetUnitGorefiendsGraspMelee()
        {
            UnitGorefiendsGraspMelee = null;
            UnitGorefiendsGraspMelee = NearbyUnFriendlyPlayers.FirstOrDefault<WoWUnit>(unit => ((((BasicCheck(unit) && (TalentSort(unit) == 1)) && (unit.GotTarget && (unit.get_CurrentTarget() != Me))) && ((FarFriendlyPlayers.Contains(unit.get_CurrentTarget()) && !InvulnerableSpell(unit)) && (!DebuffRoot(unit) && (unit.get_CurrentTarget().HealthPercent <= THSettings.Instance.GorefiendsGraspMeleeHP)))) && ((((Me.HealthPercent > THSettings.Instance.PriorityHeal) && (Me.HealthPercent > (unit.get_CurrentTarget().HealthPercent + 10.0))) && ((GetDistance(unit) > 10f) && (GetDistance(unit.get_CurrentTarget()) > 10f))) && FacingOverride(unit))) && Attackable(unit, 20));
            return BasicCheck(UnitGorefiendsGraspMelee);
        }

        private static bool GetUnitMindFreezeInterrupt()
        {
            UnitInterrupt = null;
            if (Me.get_CurrentMap().IsBattleground || Me.get_CurrentMap().IsArena)
            {
                UnitInterrupt = NearbyUnFriendlyPlayers.FirstOrDefault<WoWUnit>(unit => ((BasicCheck(unit) && ((THSettings.Instance.InterruptAll || ((THSettings.Instance.InterruptTarget && (Me.get_CurrentTarget() != null)) && (unit == Me.get_CurrentTarget()))) || ((THSettings.Instance.InterruptFocus && (Me.get_FocusedUnit() != null)) && (unit == Me.get_FocusedUnit())))) && (FacingOverride(unit) && InterruptCheck(unit, (double) THSettings.Instance.MindFreezeInterruptMs, false))) && Attackable(unit, 5));
            }
            else
            {
                UnitInterrupt = NearbyUnFriendlyUnits.FirstOrDefault<WoWUnit>(unit => (((BasicCheck(unit) && ((Me.get_CurrentMap().Name == "Proving Grounds") || unit.Combat)) && ((THSettings.Instance.InterruptAll || ((THSettings.Instance.InterruptTarget && (Me.get_CurrentTarget() != null)) && (unit == Me.get_CurrentTarget()))) || ((THSettings.Instance.InterruptFocus && (Me.get_FocusedUnit() != null)) && (unit == Me.get_FocusedUnit())))) && ((FacingOverride(unit) && FarFriendlyPlayers.Contains(unit.get_CurrentTarget())) && InterruptCheck(unit, (double) THSettings.Instance.MindFreezeInterruptMs, false))) && Attackable(unit, 5));
            }
            return BasicCheck(UnitInterrupt);
        }

        private static bool GetUnitPetChargeEnemyLowHP()
        {
            UnitPetStunEnemyLowHP = null;
            if (Me.get_CurrentMap().IsBattleground || Me.get_CurrentMap().IsArena)
            {
                UnitPetStunEnemyLowHP = NearbyUnFriendlyPlayers.FirstOrDefault<WoWUnit>(unit => (((BasicCheck(unit) && (GetDistance(unit, Me.get_Pet()) < 30f)) && ((GetDistance(unit, Me.get_Pet()) > 5f) && (unit.HealthPercent <= THSettings.Instance.ChargeStunEnemyHP))) && !Invulnerable(unit)) && !DebuffCC(unit));
            }
            else
            {
                UnitPetStunEnemyLowHP = NearbyUnFriendlyPlayers.FirstOrDefault<WoWUnit>(unit => (((BasicCheck(unit) && unit.Combat) && ((GetDistance(unit, Me.get_Pet()) < 30f) && (GetDistance(unit, Me.get_Pet()) > 5f))) && ((unit.HealthPercent <= THSettings.Instance.ChargeStunEnemyHP) && !Invulnerable(unit))) && !DebuffCC(unit));
            }
            return BasicCheck(UnitPetStunEnemyLowHP);
        }

        private static bool GetUnitPetChargeInterrupt()
        {
            UnitInterrupt = null;
            if (Me.get_CurrentMap().IsBattleground || Me.get_CurrentMap().IsArena)
            {
                UnitInterrupt = NearbyUnFriendlyPlayers.FirstOrDefault<WoWUnit>(unit => ((BasicCheck(unit) && ((THSettings.Instance.InterruptAll || ((THSettings.Instance.InterruptTarget && (Me.get_CurrentTarget() != null)) && (unit == Me.get_CurrentTarget()))) || ((THSettings.Instance.InterruptFocus && (Me.get_FocusedUnit() != null)) && (unit == Me.get_FocusedUnit())))) && (((unit.get_Location().Distance(Me.get_Pet().get_Location()) >= 5f) && (unit.get_Location().Distance(Me.get_Pet().get_Location()) <= 30f)) && (!InvulnerableSpell(unit) && InterruptCheck(unit, (double) THSettings.Instance.ChargeInterruptMS, true)))) && Attackable(unit, 40));
            }
            else
            {
                UnitInterrupt = NearbyUnFriendlyUnits.FirstOrDefault<WoWUnit>(unit => (((BasicCheck(unit) && unit.Combat) && ((THSettings.Instance.InterruptAll || ((THSettings.Instance.InterruptTarget && (Me.get_CurrentTarget() != null)) && (unit == Me.get_CurrentTarget()))) || ((THSettings.Instance.InterruptFocus && (Me.get_FocusedUnit() != null)) && (unit == Me.get_FocusedUnit())))) && (((unit.get_Location().Distance(Me.get_Pet().get_Location()) >= 5f) && (unit.get_Location().Distance(Me.get_Pet().get_Location()) <= 30f)) && (FarFriendlyPlayers.Contains(unit.get_CurrentTarget()) && InterruptCheck(unit, (double) THSettings.Instance.ChargeInterruptMS, true)))) && Attackable(unit, 40));
            }
            return BasicCheck(UnitInterrupt);
        }

        private static bool GetUnitPetChargeSaveFriendLowHP()
        {
            UnitPetStunSaveFriendLowHP = null;
            if (Me.get_CurrentMap().IsBattleground || Me.get_CurrentMap().IsArena)
            {
                UnitPetStunSaveFriendLowHP = NearbyUnFriendlyPlayers.FirstOrDefault<WoWUnit>(unit => (((BasicCheck(unit) && (GetDistance(unit, Me.get_Pet()) < 30f)) && ((GetDistance(unit, Me.get_Pet()) > 5f) && unit.GotTarget)) && ((FarFriendlyPlayers.Contains(unit.get_CurrentTarget()) && (unit.get_CurrentTarget().HealthPercent <= THSettings.Instance.ChargeStunFriendHP)) && (!DebuffCCBreakonDamage(unit) && !InvulnerableStun(unit)))) && !Invulnerable(unit));
            }
            else
            {
                UnitPetStunSaveFriendLowHP = NearbyUnFriendlyUnits.FirstOrDefault<WoWUnit>(unit => ((((BasicCheck(unit) && unit.Combat) && ((GetDistance(unit, Me.get_Pet()) < 30f) && (GetDistance(unit, Me.get_Pet()) > 5f))) && ((unit.GotTarget && FarFriendlyPlayers.Contains(unit.get_CurrentTarget())) && ((unit.get_CurrentTarget().HealthPercent <= THSettings.Instance.ChargeStunFriendHP) && !DebuffCCBreakonDamage(unit)))) && !InvulnerableStun(unit)) && !Invulnerable(unit));
            }
            return BasicCheck(UnitPetStunSaveFriendLowHP);
        }

        private static bool GetUnitPetGnawEnemyLowHP()
        {
            UnitPetStunEnemyLowHP = null;
            if (Me.get_CurrentMap().IsBattleground || Me.get_CurrentMap().IsArena)
            {
                UnitPetStunEnemyLowHP = NearbyUnFriendlyPlayers.FirstOrDefault<WoWUnit>(unit => ((BasicCheck(unit) && (unit.get_Location().Distance(Me.get_Pet().get_Location()) <= 8f)) && ((unit.HealthPercent <= THSettings.Instance.GnawStunEnemyHP) && !Invulnerable(unit))) && !DebuffCC(unit));
            }
            else
            {
                UnitPetStunEnemyLowHP = NearbyUnFriendlyUnits.FirstOrDefault<WoWUnit>(unit => (((BasicCheck(unit) && unit.Combat) && ((unit.get_Location().Distance(Me.get_Pet().get_Location()) <= 8f) && (unit.HealthPercent <= THSettings.Instance.GnawStunEnemyHP))) && !Invulnerable(unit)) && !DebuffCC(unit));
            }
            return BasicCheck(UnitPetStunEnemyLowHP);
        }

        private static bool GetUnitPetGnawInterrupt()
        {
            UnitInterrupt = null;
            if (Me.get_CurrentMap().IsBattleground || Me.get_CurrentMap().IsArena)
            {
                UnitInterrupt = NearbyUnFriendlyPlayers.FirstOrDefault<WoWUnit>(unit => ((BasicCheck(unit) && ((THSettings.Instance.InterruptAll || ((THSettings.Instance.InterruptTarget && (Me.get_CurrentTarget() != null)) && (unit == Me.get_CurrentTarget()))) || ((THSettings.Instance.InterruptFocus && (Me.get_FocusedUnit() != null)) && (unit == Me.get_FocusedUnit())))) && (((unit.get_Location().Distance(Me.get_Pet().get_Location()) <= 8f) && !Invulnerable(unit)) && (!InvulnerableStun(unit) && !DebuffCCBreakonDamage(unit)))) && InterruptCheck(unit, (double) THSettings.Instance.GnawInterruptMS, true));
            }
            else
            {
                UnitInterrupt = NearbyUnFriendlyUnits.FirstOrDefault<WoWUnit>(unit => ((BasicCheck(unit) && ((THSettings.Instance.InterruptAll || ((THSettings.Instance.InterruptTarget && (Me.get_CurrentTarget() != null)) && (unit == Me.get_CurrentTarget()))) || ((THSettings.Instance.InterruptFocus && (Me.get_FocusedUnit() != null)) && (unit == Me.get_FocusedUnit())))) && ((unit.get_Location().Distance(Me.get_Pet().get_Location()) <= 8f) && FarFriendlyPlayers.Contains(unit.get_CurrentTarget()))) && InterruptCheck(unit, (double) THSettings.Instance.GnawInterruptMS, true));
            }
            return BasicCheck(UnitInterrupt);
        }

        private static bool GetUnitPetGnawSaveFriendLowHP()
        {
            UnitPetStunSaveFriendLowHP = null;
            if (Me.get_CurrentMap().IsBattleground || Me.get_CurrentMap().IsArena)
            {
                UnitPetStunSaveFriendLowHP = NearbyUnFriendlyPlayers.FirstOrDefault<WoWUnit>(unit => (((BasicCheck(unit) && (GetDistance(unit, Me.get_Pet()) < 8f)) && (unit.GotTarget && FarFriendlyPlayers.Contains(unit.get_CurrentTarget()))) && (((unit.get_CurrentTarget().HealthPercent <= THSettings.Instance.GnawStunFriendHP) && !DebuffCCBreakonDamage(unit)) && !InvulnerableStun(unit))) && !Invulnerable(unit));
            }
            else
            {
                UnitPetStunSaveFriendLowHP = NearbyUnFriendlyUnits.FirstOrDefault<WoWUnit>(unit => (((BasicCheck(unit) && unit.Combat) && ((GetDistance(unit, Me.get_Pet()) < 8f) && unit.GotTarget)) && ((FarFriendlyPlayers.Contains(unit.get_CurrentTarget()) && (unit.get_CurrentTarget().HealthPercent <= THSettings.Instance.GnawStunFriendHP)) && (!DebuffCCBreakonDamage(unit) && !InvulnerableStun(unit)))) && !Invulnerable(unit));
            }
            return BasicCheck(UnitPetStunSaveFriendLowHP);
        }

        private static bool GetUnitRaiseAlly()
        {
            GetUnitRaiseAllyLastSearch = DateTime.Now;
            UnitRaiseAlly = null;
            UnitRaiseAlly = (from unit in ObjectManager.GetObjectsOfType<WoWPlayer>(false, false)
                orderby unit.MaxHealth
                select unit).FirstOrDefault<WoWPlayer>(unit => (((unit != null) && unit.IsValid) && (!unit.IsAlive && (unit.Distance < 40.0))) && InLineOfSpellSightCheck((WoWUnit) unit));
            return BasicCheck((WoWUnit) UnitRaiseAlly);
        }

        private static Composite GetUnits()
        {
            return (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                EnemyListCacheClear();
                FriendListCacheClear();
                NearbyFriendlyPlayers.Clear();
                NearbyFriendlyUnits.Clear();
                FarFriendlyPlayers.Clear();
                FarFriendlyUnits.Clear();
                NearbyUnFriendlyPlayers.Clear();
                NearbyUnFriendlyUnits.Clear();
                FarUnFriendlyPlayers.Clear();
                FarUnFriendlyUnits.Clear();
                foreach (WoWUnit unit in from unit in GetAllUnits()
                    where ((unit.CanSelect && unit.IsAlive) && (GetDistance(unit) < 60f)) && !Blacklist.Contains(unit.Guid, ((BlacklistFlags) BlacklistFlags.Pull) | (((BlacklistFlags) BlacklistFlags.Interact) | (((BlacklistFlags) BlacklistFlags.Node) | (((BlacklistFlags) BlacklistFlags.Combat) | ((BlacklistFlags) BlacklistFlags.Loot)))))
                    select unit)
                {
                    if (IsMyPartyRaidMember(unit))
                    {
                        WoWPlayer player = unit as WoWPlayer;
                        if ((player != null) || NeedHealUnit(unit))
                        {
                            FarFriendlyPlayers.Add(unit);
                            FarFriendlyUnits.Add(unit);
                            if (unit.Distance <= 40.0)
                            {
                                NearbyFriendlyUnits.Add(unit);
                                NearbyFriendlyPlayers.Add(unit);
                            }
                        }
                        else
                        {
                            FarFriendlyUnits.Add(unit);
                            if (unit.Distance <= 40.0)
                            {
                                NearbyFriendlyUnits.Add(unit);
                            }
                        }
                        continue;
                    }
                    if (IsEnemy(unit))
                    {
                        WoWPlayer player2 = unit as WoWPlayer;
                        if (player2 != null)
                        {
                            FarUnFriendlyPlayers.Add(unit);
                            FarUnFriendlyUnits.Add(unit);
                            if (unit.Distance <= 40.0)
                            {
                                NearbyUnFriendlyUnits.Add(unit);
                                NearbyUnFriendlyPlayers.Add(unit);
                            }
                            continue;
                        }
                        FarUnFriendlyUnits.Add(unit);
                        if (unit.Distance <= 40.0)
                        {
                            NearbyUnFriendlyUnits.Add(unit);
                        }
                    }
                }
                return (RunStatus) RunStatus.Failure;
            });
        }

        private static bool GetUnitStrangulateInterrupt()
        {
            UnitInterrupt = null;
            if (Me.get_CurrentMap().IsBattleground || Me.get_CurrentMap().IsArena)
            {
                UnitInterrupt = NearbyUnFriendlyPlayers.FirstOrDefault<WoWUnit>(unit => ((BasicCheck(unit) && ((THSettings.Instance.InterruptAll || ((THSettings.Instance.InterruptTarget && (Me.get_CurrentTarget() != null)) && (unit == Me.get_CurrentTarget()))) || ((THSettings.Instance.InterruptFocus && (Me.get_FocusedUnit() != null)) && (unit == Me.get_FocusedUnit())))) && ((((unit.Distance <= 30.0) && !Invulnerable(unit)) && (!InvulnerableSpell(unit) && !DebuffCCBreakonDamage(unit))) && (FacingOverride(unit) && InterruptCheck(unit, (double) THSettings.Instance.StrangulateInterruptMs, false)))) && InLineOfSpellSightCheck(unit));
            }
            else
            {
                UnitInterrupt = NearbyUnFriendlyPlayers.FirstOrDefault<WoWUnit>(unit => (((BasicCheck(unit) && unit.Combat) && ((THSettings.Instance.InterruptAll || ((THSettings.Instance.InterruptTarget && (Me.get_CurrentTarget() != null)) && (unit == Me.get_CurrentTarget()))) || ((THSettings.Instance.InterruptFocus && (Me.get_FocusedUnit() != null)) && (unit == Me.get_FocusedUnit())))) && (((unit.Distance <= 30.0) && FacingOverride(unit)) && (FarFriendlyPlayers.Contains(unit.get_CurrentTarget()) && InterruptCheck(unit, (double) THSettings.Instance.StrangulateInterruptMs, false)))) && InLineOfSpellSightCheck(unit));
            }
            return BasicCheck(UnitInterrupt);
        }

        private static bool GetUnitStrangulateLow()
        {
            UnitStrangulateLow = null;
            UnitStrangulateLow = (from unit in NearbyUnFriendlyPlayers.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck))
                orderby unit.CurrentHealth
                select unit).FirstOrDefault<WoWUnit>(unit => (((unit.HealthPercent <= THSettings.Instance.StrangulateLowHP) && !MyAura("Remorseless Winter", unit)) && (TalentSort(unit) >= 3)) && Attackable(unit, 40));
            return BasicCheck(UnitStrangulateLow);
        }

        private static void GlobalCheck()
        {
            if (GlobalCheckTime <= DateTime.Now)
            {
                GlobalCheckTime = DateTime.Now + TimeSpan.FromSeconds(30.0);
                UpdateMyLatency();
                UpdateEventHandler();
                if (Me.get_CurrentMap().IsRaid)
                {
                    CurrentTargetCheckTimeOut = TimeSpan.FromMilliseconds(500.0);
                }
                else if (Me.get_CurrentMap().IsArena || Me.get_CurrentMap().IsBattleground)
                {
                    CurrentTargetCheckTimeOut = TimeSpan.FromMilliseconds(50.0);
                }
                else
                {
                    CurrentTargetCheckTimeOut = TimeSpan.FromMilliseconds(100.0);
                }
            }
        }

        private static Composite GorefiendsGraspAggro()
        {
            return (Composite) new Decorator(ret => (((THSettings.Instance.GorefiendsGraspAggro && ((LastTaunt + TimeSpan.FromSeconds(1.0)) < DateTime.Now)) && (Me.get_CurrentMap().IsDungeon || Me.get_CurrentMap().IsRaid)) && (Me.Combat && CanCastCheck("Gorefiend's Grasp", true))) && GetUnitGorefiendsGraspAggro(), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Gorefiend's Grasp", (WoWUnit) Me, "GorefiendsGraspAggro");
                return (RunStatus) RunStatus.Failure;
            }));
        }

        private static Composite GorefiendsGraspAoE()
        {
            return (Composite) new Decorator(ret => (((THSettings.Instance.GorefiendsGraspAoE && Me.Combat) && (Me.get_CurrentMap().IsArena || Me.get_CurrentMap().IsBattleground)) && CanCastCheck("Gorefiend's Grasp", false)) && GetUnitGorefiendsGraspAoE(), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                FacingDelay = DateTime.Now;
                if ((THSettings.Instance.AutoFace && ((FacingDelay + TimeSpan.FromMilliseconds(100.0)) > DateTime.Now)) && !Me.IsFacing((WoWObject) UnitGorefiendsGraspAoE))
                {
                    Me.SetFacing(UnitGorefiendsGraspAoE);
                }
                CastSpell("Gorefiend's Grasp", UnitGorefiendsGraspAoE, "GorefiendsGraspAoE");
            }));
        }

        private static void GorefiendsGraspInterruptVoid()
        {
            if (((THSettings.Instance.GorefiendsGraspInterrupt && ((LastInterrupt + TimeSpan.FromMilliseconds(1000.0)) < DateTime.Now)) && (Me.Combat && CanCastCheck("Gorefiend's Grasp", true))) && GetUnitGorefiendsGraspInterrupt())
            {
                if (Me.IsCasting)
                {
                    SpellManager.StopCasting();
                }
                if ((UnitInterrupt.IsCasting && (UnitInterrupt.CurrentCastTimeLeft.TotalMilliseconds > (MyLatency + 50.0))) || UnitInterrupt.IsChanneling)
                {
                    CastSpell("Gorefiend's Grasp", (WoWUnit) Me, "GorefiendsGraspInterruptVoid");
                    LastInterrupt = DateTime.Now;
                }
            }
        }

        private static Composite GorefiendsGraspKiter()
        {
            return (Composite) new Decorator(delegate (object ret) {
                if ((((!THSettings.Instance.GorefiendsGraspKiter || (THSettings.Instance.GorefiendsGraspKiterMinDist <= 0)) || (((LastGripSnare + TimeSpan.FromSeconds(2.0)) >= DateTime.Now) || !CurrentTargetAttackable(20.0, false, false))) || ((InvulnerableSpell(Me.get_CurrentTarget()) || Me.get_CurrentTarget().IsBoss) || (DebuffRoot(Me.get_CurrentTarget()) || (Me.get_CurrentTarget().Distance < THSettings.Instance.DeathGripMinDistance)))) || (IsMoving(Me.get_CurrentTarget()) && Me.get_CurrentTarget().IsSafelyFacing((WoWObject) Me)))
                {
                    return false;
                }
                return CanCastCheck("Gorefiend's Grasp", false);
            }, (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                LastGripSnare = DateTime.Now;
                CastSpell("Gorefiend's Grasp", (WoWUnit) Me, "GorefiendsGraspKiter");
            }));
        }

        private static Composite GorefiendsGraspMelee()
        {
            return (Composite) new Decorator(ret => ((((THSettings.Instance.GorefiendsGraspMelee && ((LastGripSnare + TimeSpan.FromSeconds(2.0)) < DateTime.Now)) && Me.Combat) && (Me.get_CurrentMap().IsArena || Me.get_CurrentMap().IsBattleground)) && CanCastCheck("Gorefiend's Grasp", false)) && GetUnitGorefiendsGraspMelee(), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                LastGripSnare = DateTime.Now;
                CastSpell("Gorefiend's Grasp", (WoWUnit) Me, "GorefiendsGraspMelee");
            }));
        }

        private static bool HasEnemyDontHaveBloodPlague()
        {
            return NearbyUnFriendlyUnits.Any<WoWUnit>(unit => ((((BasicCheck(unit) && !unit.IsPet) && (((Me.get_CurrentMap().Name == "Proving Grounds") || IsDummy(unit)) || ((unit.Combat && unit.GotTarget) && FarFriendlyPlayers.Contains(unit.get_CurrentTarget())))) && !MyAura("Blood Plague", unit)) && Attackable(unit, 10 + GlyphprivateofPestilenceBonus)));
        }

        private static bool HasEnemyDontHaveBloodPlagueorFrostFever()
        {
            return NearbyUnFriendlyUnits.Any<WoWUnit>(delegate (WoWUnit unit) {
                if ((!BasicCheck(unit) || unit.IsPet) || (MyAura("Frost Fever", unit) && MyAura("Blood Plague", unit)))
                {
                    return false;
                }
                return Attackable(unit, 10 + GlyphprivateofPestilenceBonus);
            });
        }

        private static bool HasEnemyDontHaveFrostFever()
        {
            return NearbyUnFriendlyUnits.Any<WoWUnit>(unit => ((((BasicCheck(unit) && !unit.IsPet) && (((Me.get_CurrentMap().Name == "Proving Grounds") || IsDummy(unit)) || ((unit.Combat && unit.GotTarget) && FarFriendlyPlayers.Contains(unit.get_CurrentTarget())))) && !MyAura("Frost Fever", unit)) && Attackable(unit, 10)));
        }

        private static bool HasEnemyHaveBloodPlague()
        {
            return NearbyUnFriendlyUnits.Any<WoWUnit>(unit => ((((BasicCheck(unit) && !unit.IsPet) && (((Me.get_CurrentMap().Name == "Proving Grounds") || IsDummy(unit)) || ((unit.Combat && unit.GotTarget) && FarFriendlyPlayers.Contains(unit.get_CurrentTarget())))) && MyAura("Blood Plague", unit)) && Attackable(unit, 10)));
        }

        private static bool HasEnemyHaveFrostFever()
        {
            return NearbyUnFriendlyUnits.Any<WoWUnit>(unit => ((((BasicCheck(unit) && !unit.IsPet) && (((Me.get_CurrentMap().Name == "Proving Grounds") || IsDummy(unit)) || ((unit.Combat && unit.GotTarget) && FarFriendlyPlayers.Contains(unit.get_CurrentTarget())))) && MyAura("Frost Fever", unit)) && Attackable(unit, 10 + GlyphprivateofPestilenceBonus)));
        }

        private static bool HasEnemyNear(WoWUnit unitCenter, float distance)
        {
            return FarUnFriendlyUnits.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck)).Any<WoWUnit>(delegate (WoWUnit unit) {
                if ((!(Me.get_CurrentMap().Name == "Proving Grounds") && !IsDummy(unit)) && ((!unit.Combat || (unit.MaxHealth <= (MeMaxHealth * 0.2))) || (!unit.GotTarget || !FarFriendlyUnits.Contains(unit.get_CurrentTarget()))))
                {
                    return false;
                }
                return (GetDistance(unitCenter, unit) <= distance);
            });
        }

        private static bool HasEnemyNearGotCCBreakonDamge(WoWUnit unitCenter, float distance)
        {
            if (!Me.get_CurrentMap().IsArena && !Me.get_CurrentMap().IsBattleground)
            {
                return false;
            }
            return FarUnFriendlyPlayers.Where<WoWUnit>(new Func<WoWUnit, bool>(Classname.BasicCheck)).Any<WoWUnit>(unit => ((((unit.MaxHealth > (MeMaxHealth * 0.3)) && (((Me.get_CurrentMap().Name == "Proving Grounds") || IsDummy(unit)) || (unit.Combat && FarFriendlyPlayers.Contains(unit.get_CurrentTarget())))) && (GetDistance(unitCenter, unit) <= distance)) && DebuffCCBreakonDamage(unit)));
        }

        private static bool HasMagicBuffDispel(WoWUnit target)
        {
            return target.GetAllAuras().Any<WoWAura>(a => ((a.IsActive && !a.IsHarmful) && (a.get_Spell().get_DispelType() == ((WoWDispelType) ((int) WoWDispelType.Magic)))));
        }

        private static bool HasMeleeFriendDPSTarget(WoWUnit target, double distance)
        {
            Func<WoWUnit, bool> predicate = null;
            if (!Me.get_CurrentMap().IsArena && !Me.get_CurrentMap().IsBattleground)
            {
                return FarFriendlyPlayers.Any<WoWUnit>(unit => ((((BasicCheck(unit) && (unit.get_CurrentTarget() != null)) && (unit.get_CurrentTarget().IsValid && (unit.get_CurrentTarget() == target))) && (unit.get_Location().Distance(target.get_Location()) <= distance)) && !DebuffCC(unit)));
            }
            if (predicate == null)
            {
                predicate = unit => (((BasicCheck(unit) && (unit.get_CurrentTarget() != null)) && (unit.get_CurrentTarget().IsValid && (unit.get_CurrentTarget() == target))) && ((TalentSort(unit) == 1) && (unit.get_Location().Distance(target.get_Location()) <= distance))) && !DebuffCC(unit);
            }
            return FarFriendlyPlayers.Any<WoWUnit>(predicate);
        }

        private static bool HasPaladinPriestAround()
        {
            return NearbyUnFriendlyPlayers.Any<WoWUnit>(unit => ((((BasicCheck(unit) && (unit.Distance < 31.0)) && ((unit.get_Class() == ((WoWClass) ((uint) WoWClass.Paladin))) || (unit.get_Class() == ((WoWClass) ((uint) WoWClass.Priest))))) && !DebuffCC(unit)) && InLineOfSpellSightCheck(unit)));
        }

        private static double HealWeight(WoWUnit target)
        {
            Func<WoWUnit, bool> predicate = null;
            Func<WoWUnit, bool> func2 = null;
            if (!BasicCheck(target))
            {
                return 1000.0;
            }
            if (!target.Combat)
            {
                return target.HealthPercent;
            }
            int num = 0;
            if (Me.get_CurrentMap().IsArena || Me.get_CurrentMap().IsBattleground)
            {
                if (predicate == null)
                {
                    predicate = unit => (BasicCheck(unit) && unit.Combat) && (unit.get_CurrentTarget() == target);
                }
                foreach (WoWUnit unit in FarUnFriendlyPlayers.Where<WoWUnit>(predicate))
                {
                    if ((TalentSort(unit) < 4) && BuffBurst(unit))
                    {
                        num += 5;
                    }
                    else
                    {
                        num += 3;
                    }
                }
            }
            else
            {
                if (func2 == null)
                {
                    func2 = unit => (BasicCheck(unit) && unit.Combat) && (unit.get_CurrentTarget() == target);
                }
                foreach (WoWUnit unit2 in FarUnFriendlyUnits.Where<WoWUnit>(func2))
                {
                    if (unit2.IsBoss)
                    {
                        num += 5;
                    }
                    else
                    {
                        num++;
                    }
                }
            }
            return (target.HealthPercent - num);
        }

        private static Composite HeartStrike()
        {
            return (Composite) new Decorator(delegate (object ret) {
                if (((!THSettings.Instance.HeartStrike || !CurrentTargetAttackable(5.0, false, false)) || !FacingOverride(Me.get_CurrentTarget())) || (!CanUseDeathRune() && (Me.BloodRuneCount <= 0)))
                {
                    return false;
                }
                return CanCastCheck("Heart Strike", false);
            }, (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Heart Strike", Me.get_CurrentTarget(), "");
            }));
        }

        private static Composite HeartStrikeAoE()
        {
            return (Composite) new Decorator(ret => ((THSettings.Instance.HeartStrike && CurrentTargetAttackable(5.0, false, false)) && (FacingOverride(Me.get_CurrentTarget()) && CanCastCheck("Heart Strike", false))) && (CountEnemyNear((WoWUnit) Me, 15f) < 4.0), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Heart Strike", Me.get_CurrentTarget(), "");
            }));
        }

        private static Composite Hold()
        {
            return (Composite) new Decorator(delegate (object ret) {
                if ((((Me.IsValid && StyxWoW.IsInWorld) && Me.IsAlive) && (THSettings.Instance.AttackOOC || Me.Combat)) && (!MeHasAura("Food") || (Me.HealthPercent >= THSettings.Instance.DoNotHealAbove)))
                {
                    return MeHasAura("Resurrection Sickness");
                }
                return true;
            }, (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                if (Me.IsAutoAttacking)
                {
                    Lua.DoString("RunMacroText('/stopattack');", "WoW.lua");
                }
                Styx.Common.Logging.Write("Hold on Eat/Drink/Dead/Not in Game/Sesurrection Sickness/Attack Out of Combat");
                return (RunStatus) RunStatus.Success;
            }));
        }

        private static bool HoldSpendingRunicPower()
        {
            if (PlayerRunicPower() > 80.0)
            {
                return false;
            }
            return (((PlayerRunicPower() < 50.0) && MeHasAura("Conversion")) || ((THSettings.Instance.LichborneHeal && (Me.HealthPercent < THSettings.Instance.DoNotHealAbove)) && MeHasAura("Lichborne")));
        }

        private static Composite HornofWinter()
        {
            return (Composite) new Decorator(ret => (((THSettings.Instance.HornofWinter && (LastCastSpell != "Death Grip")) && ((LastCastSpell != "Howling Blast") && (LastCastSpell != "Outbreak"))) && ((Me.Combat && (PlayerRunicPower() < 80.0)) && CurrentTargetAttackable(30.0, false, false))) && CanCastCheck("Horn of Winter", false), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Horn of Winter", (WoWUnit) Me, "");
            }));
        }

        private static Composite HornofWinterBuff()
        {
            return (Composite) new Decorator(ret => (THSettings.Instance.HornofWinter && !MeHasAura("Horn of Winter")) && CanCastCheck("Horn of Winter", false), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Horn of Winter", (WoWUnit) Me, "HornofWinterBuff");
            }));
        }

        private static Composite HowlingBlastAoE()
        {
            return (Composite) new Decorator(ret => ((THSettings.Instance.HowlingBlast && CurrentTargetAttackable(30.0, false, false)) && FacingOverride(Me.get_CurrentTarget())) && CanCastCheck("Howling Blast", false), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                LastFrostFeverDebuff = DateTime.Now;
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Howling Blast", Me.get_CurrentTarget(), "HowlingBlastAoE");
            }));
        }

        private static Composite HowlingBlastAoELow()
        {
            return (Composite) new Decorator(ret => ((THSettings.Instance.HowlingBlast && CurrentTargetAttackable(30.0, false, false)) && (FacingOverride(Me.get_CurrentTarget()) && !HasEnemyNearGotCCBreakonDamge(Me.get_CurrentTarget(), 10f))) && CanCastCheck("Howling Blast", false), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                LastFrostFeverDebuff = DateTime.Now;
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Howling Blast", Me.get_CurrentTarget(), "HowlingBlastAoELow");
            }));
        }

        private static Composite HowlingBlastDebuff()
        {
            return (Composite) new Decorator(ret => ((((THSettings.Instance.HowlingBlast && ((LastFrostFeverDebuff + TimeSpan.FromMilliseconds(2000.0)) < DateTime.Now)) && (CurrentTargetAttackable(30.0, false, false) && FacingOverride(Me.get_CurrentTarget()))) && (CanCastCheck("Howling Blast", false) && ((MyAuraTimeLeft("Frost Fever", Me.get_CurrentTarget()) < 3000.0) || !SpellManager.HasSpell("Obliterate")))) && ((!SpellManager.HasSpell("Outbreak") || !THSettings.Instance.Outbreak) || (SpellManager.HasSpell("Outbreak") && (GetSpellCooldown("Outbreak").TotalMilliseconds > 3000.0)))) && !HasEnemyNearGotCCBreakonDamge(Me.get_CurrentTarget(), 10f), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                LastFrostFeverDebuff = DateTime.Now;
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Howling Blast", Me.get_CurrentTarget(), "HowlingBlastDebuff");
            }));
        }

        private static Composite HowlingBlastDW()
        {
            return (Composite) new Decorator(ret => (((THSettings.Instance.HowlingBlast && CurrentTargetAttackable(30.0, false, false)) && (FacingOverride(Me.get_CurrentTarget()) && CanCastCheck("Howling Blast", false))) && !CanCastCheck("Obliterate", false)) && !HasEnemyNearGotCCBreakonDamge(Me.get_CurrentTarget(), 10f), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                LastFrostFeverDebuff = DateTime.Now;
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Howling Blast", Me.get_CurrentTarget(), "HowlingBlastDW");
            }));
        }

        private static Composite HowlingBlastProc()
        {
            return (Composite) new Decorator(ret => (((THSettings.Instance.HowlingBlast && ((LastProc + TimeSpan.FromMilliseconds(1500.0)) < DateTime.Now)) && (CurrentTargetAttackable(30.0, false, false) && MeHasAura("Freezing Fog"))) && (FacingOverride(Me.get_CurrentTarget()) && CanCastCheck("Howling Blast", false))) && !HasEnemyNearGotCCBreakonDamge(Me.get_CurrentTarget(), 10f), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                LastFrostFeverDebuff = DateTime.Now;
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Howling Blast", Me.get_CurrentTarget(), "HowlingBlastProc");
                LastProc = DateTime.Now;
            }));
        }

        private static Composite Huddle()
        {
            return (Composite) new Decorator(ret => ((THSettings.Instance.Huddle && Me.GotAlivePet) && (Me.get_Pet().HealthPercent <= THSettings.Instance.HuddleHP)) && PetCanCastAction("Huddle"), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                PetCastAction("Huddle", Me.get_Pet());
                return (RunStatus) RunStatus.Failure;
            }));
        }

        private static Composite IceboundFortitude()
        {
            return (Composite) new Decorator(ret => ((THSettings.Instance.IceboundFortitude && Me.Combat) && (CurrentTargetAttackable(30.0, false, false) && (Me.HealthPercent <= THSettings.Instance.IceboundFortitudeHP))) && CanCastCheck("Icebound Fortitude", true), (Composite) new Styx.TreeSharp.Action(delegate (object ret) {
                CastSpell("Icebound Fortitude", (WoWUnit) Me, "");
                return (RunStatus) RunStatus.Failure;
            }));
        }

        private static Composite IceboundFortitudeStun()
        {
            return (Composite) new Decorator(ret => ((THSettings.Instance.IceboundFortitudeStun && DebuffStunDuration((WoWUnit) Me, (double) THSettings.Instance.IceboundFortitudeStunDuration)) && CurrentTargetAttackable(30.0, false, false)) && CanCastCheck("Icebound Fortitude", true), (Composite) new Styx.TreeSharp.Action(delegate (object ret) {
                CastSpell("Icebound Fortitude", (WoWUnit) Me, "IceboundFortitudeStun");
                return (RunStatus) RunStatus.Failure;
            }));
        }

        private static Composite IcyTouch()
        {
            return (Composite) new Decorator(ret => (((THSettings.Instance.IcyTouch && ((LastFrostFeverDebuff + TimeSpan.FromMilliseconds(2000.0)) < DateTime.Now)) && (CurrentTargetAttackable(30.0, false, false) && FacingOverride(Me.get_CurrentTarget()))) && (MyAuraTimeLeft("Frost Fever", Me.get_CurrentTarget()) < 2000.0)) && CanCastCheck("Icy Touch", false), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                LastFrostFeverDebuff = DateTime.Now;
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Icy Touch", Me.get_CurrentTarget(), "");
            }));
        }

        private static Composite IcyTouchConversion()
        {
            return (Composite) new Decorator(ret => (((THSettings.Instance.IcyTouch && CurrentTargetAttackable(30.0, false, false)) && (FacingOverride(Me.get_CurrentTarget()) && (Me.FrostRuneCount > 0))) && (Me.BloodRuneCount == 0)) && CanCastCheck("Icy Touch", false), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                LastFrostFeverDebuff = DateTime.Now;
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Icy Touch", Me.get_CurrentTarget(), "IcyTouchConversion");
            }));
        }

        private static Composite IcyTouchDebuffBlood()
        {
            return (Composite) new Decorator(ret => (((THSettings.Instance.IcyTouch && ((LastFrostFeverDebuff + TimeSpan.FromMilliseconds(2000.0)) < DateTime.Now)) && (CurrentTargetAttackable(30.0, false, false) && FacingOverride(Me.get_CurrentTarget()))) && (((MyAuraTimeLeft("Frost Fever", Me.get_CurrentTarget()) < 2000.0) && CanCastCheck("Icy Touch", false)) && SpellManager.HasSpell("Outbreak"))) && (GetSpellCooldown("Outbreak").TotalMilliseconds > 3000.0), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                LastFrostFeverDebuff = DateTime.Now;
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Icy Touch", Me.get_CurrentTarget(), "IcyTouchDebuffBlood");
            }));
        }

        private static Composite IcyTouchDebuffBloodAoE()
        {
            return (Composite) new Decorator(delegate (object ret) {
                if (((!THSettings.Instance.IcyTouch || ((LastFrostFeverDebuff + TimeSpan.FromMilliseconds(2000.0)) >= DateTime.Now)) || (!CurrentTargetAttackable(30.0, false, false) || !FacingOverride(Me.get_CurrentTarget()))) || (!CanCastCheck("Icy Touch", false) || ((SpellManager.HasSpell("Outbreak") && THSettings.Instance.Outbreak) && (!SpellManager.HasSpell("Outbreak") || (GetSpellCooldown("Outbreak").TotalMilliseconds <= 3000.0)))))
                {
                    return false;
                }
                return !HasEnemyDontHaveFrostFever();
            }, (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                LastFrostFeverDebuff = DateTime.Now;
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Icy Touch", Me.get_CurrentTarget(), "IcyTouchDebuffBloodAoE");
            }));
        }

        private static Composite IcyTouchDebuffFrost()
        {
            return (Composite) new Decorator(ret => ((((THSettings.Instance.IcyTouch && ((LastFrostFeverDebuff + TimeSpan.FromMilliseconds(2000.0)) < DateTime.Now)) && (CurrentTargetAttackable(30.0, false, false) && FacingOverride(Me.get_CurrentTarget()))) && ((MyAuraTimeLeft("Frost Fever", Me.get_CurrentTarget()) < 3000.0) || (!SpellManager.HasSpell("Howling Blast") && (UseSpecialization == 2)))) && CanCastCheck("Icy Touch", false)) && ((!SpellManager.HasSpell("Outbreak") || !THSettings.Instance.Outbreak) || (SpellManager.HasSpell("Outbreak") && (GetSpellCooldown("Outbreak").TotalMilliseconds > 3000.0))), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                LastFrostFeverDebuff = DateTime.Now;
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Icy Touch", Me.get_CurrentTarget(), "IcyTouchDebuffFrost");
            }));
        }

        private static Composite IcyTouchDebuffUnholy()
        {
            return (Composite) new Decorator(delegate (object ret) {
                if (((!THSettings.Instance.IcyTouch || ((LastFrostFeverDebuff + TimeSpan.FromMilliseconds(2000.0)) >= DateTime.Now)) || (!CurrentTargetAttackable(30.0, false, false) || !FacingOverride(Me.get_CurrentTarget()))) || (((Me.FrostRuneCount <= 0) || (MyAuraTimeLeft("Frost Fever", Me.get_CurrentTarget()) >= 1000.0)) || !CanCastCheck("Icy Touch", false)))
                {
                    return false;
                }
                return (!SpellManager.HasSpell("Outbreak") || !THSettings.Instance.Outbreak) || (SpellManager.HasSpell("Outbreak") && (GetSpellCooldown("Outbreak").TotalMilliseconds > 3000.0));
            }, (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                LastFrostFeverDebuff = DateTime.Now;
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Icy Touch", Me.get_CurrentTarget(), "IcyTouchDebuffUnholy");
            }));
        }

        private static Composite IcyTouchDispel()
        {
            return (Composite) new Decorator(delegate (object ret) {
                if ((((!THSettings.Instance.IcyTouch || !CurrentTargetAttackable(30.0, false, false)) || (!Me.get_CurrentTarget().IsPlayer || !FacingOverride(Me.get_CurrentTarget()))) || !HasGlyph.Contains("58631")) || ((!UnitHasAura("Hand of Protection", Me.get_CurrentTarget()) && !UnitHasAura("Earth Shield", Me.get_CurrentTarget())) && ((!UnitHasAura("Nature's Swiftness", Me.get_CurrentTarget()) && !UnitHasAura("Icy Veins", Me.get_CurrentTarget())) && !UnitHasAura("Master's Call", Me.get_CurrentTarget()))))
                {
                    return false;
                }
                return CanCastCheck("Icy Touch", false);
            }, (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                LastFrostFeverDebuff = DateTime.Now;
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Icy Touch", Me.get_CurrentTarget(), "IcyTouchDispel");
            }));
        }

        private static Composite IcyTouchDispelLowPriority()
        {
            return (Composite) new Decorator(ret => ((((THSettings.Instance.IcyTouch && CurrentTargetAttackable(30.0, false, false)) && (FacingOverride(Me.get_CurrentTarget()) && HasGlyph.Contains("58631"))) && (HasMagicBuffDispel(Me.get_CurrentTarget()) && (CanUseDeathRune() || (Me.FrostRuneCount > 0)))) && CanCastCheck("Icy Touch", false)) && CanIcyTouchDispel(Me.get_CurrentTarget()), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                LastFrostFeverDebuff = DateTime.Now;
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Icy Touch", Me.get_CurrentTarget(), "IcyTouchDispelLowPriority");
            }));
        }

        private static Composite IcyTouchUnholyAoE()
        {
            return (Composite) new Decorator(ret => ((THSettings.Instance.IcyTouch && CurrentTargetAttackable(30.0, false, false)) && FacingOverride(Me.get_CurrentTarget())) && CanCastCheck("Icy Touch", false), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                LastFrostFeverDebuff = DateTime.Now;
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Icy Touch", Me.get_CurrentTarget(), "IcyTouchUnholyAoE");
            }));
        }

        private static Keys IndexToKeys(int index)
        {
            switch (index)
            {
                case 1:
                    return Keys.A;

                case 2:
                    return Keys.B;

                case 3:
                    return Keys.C;

                case 4:
                    return Keys.D;

                case 5:
                    return Keys.E;

                case 6:
                    return Keys.F;

                case 7:
                    return Keys.G;

                case 8:
                    return Keys.H;

                case 9:
                    return Keys.I;

                case 10:
                    return Keys.J;

                case 11:
                    return Keys.K;

                case 12:
                    return Keys.L;

                case 13:
                    return Keys.M;

                case 14:
                    return Keys.N;

                case 15:
                    return Keys.O;

                case 0x10:
                    return Keys.P;

                case 0x11:
                    return Keys.Q;

                case 0x12:
                    return Keys.R;

                case 0x13:
                    return Keys.S;

                case 20:
                    return Keys.T;

                case 0x15:
                    return Keys.U;

                case 0x16:
                    return Keys.V;

                case 0x17:
                    return Keys.W;

                case 0x18:
                    return Keys.X;

                case 0x19:
                    return Keys.Y;

                case 0x1a:
                    return Keys.Z;

                case 0x1b:
                    return Keys.D1;

                case 0x1c:
                    return Keys.D2;

                case 0x1d:
                    return Keys.D3;

                case 30:
                    return Keys.D4;

                case 0x1f:
                    return Keys.D5;

                case 0x20:
                    return Keys.D6;

                case 0x21:
                    return Keys.D7;

                case 0x22:
                    return Keys.D8;

                case 0x23:
                    return Keys.D9;

                case 0x24:
                    return Keys.D0;

                case 0x25:
                    return Keys.Up;

                case 0x26:
                    return Keys.Down;

                case 0x27:
                    return Keys.Left;

                case 40:
                    return Keys.Right;

                case 0x29:
                    return Keys.NumPad1;

                case 0x2a:
                    return Keys.NumPad2;

                case 0x2b:
                    return Keys.NumPad3;

                case 0x2c:
                    return Keys.NumPad4;

                case 0x2d:
                    return Keys.NumPad5;

                case 0x2e:
                    return Keys.NumPad6;

                case 0x2f:
                    return Keys.NumPad7;

                case 0x30:
                    return Keys.NumPad8;

                case 0x31:
                    return Keys.NumPad9;

                case 50:
                    return Keys.NumPad0;
            }
            return Keys.None;
        }

        internal static Keys IndexToKeysMod(int index)
        {
            switch (index)
            {
                case 1:
                    return Keys.LShiftKey;

                case 2:
                    return Keys.LControlKey;

                case 3:
                    return Keys.LMenu;
            }
            return Keys.None;
        }

        public override void Initialize()
        {
            Styx.Common.Logging.Write("");
            Styx.Common.Logging.Write(string.Concat(new object[] { "Hello level ", Me.Level, " ", Me.get_Race(), " ", Me.get_Class() }));
            Styx.Common.Logging.Write("");
            Styx.Common.Logging.Write("Thank you for using TuanHA Death Knight Special Edition");
            Styx.Common.Logging.Write("");
            Styx.Common.Logging.Write("For best Combat Routine performance, please set Custom Lag Tolerance to 400 ms.");
            Styx.Common.Logging.Write("Game Menu > Interface > Combat Check Custom Lag Toerance and Adjust the Slider to 400 ms");
            Styx.Common.Logging.Write("Best Non-AFK Botbase are LazyRaider: http://goo.gl/nf0zab or Tyrael http://goo.gl/51E0F6");
            Styx.Common.Logging.Write("For detailed installation guide, visit our new website (Google TuanHA");
            Styx.Common.Logging.Write("");
            Lua.get_Events().AttachEvent("ACTIVE_TALENT_GROUP_CHANGED", new LuaEventHandlerDelegate(Classname.UpdateStatusEvent));
            Lua.get_Events().AttachEvent("PLAYER_TALENT_UPDATE", new LuaEventHandlerDelegate(Classname.UpdateMyTalentEvent));
            Lua.get_Events().AttachEvent("GLYPH_ADDED", new LuaEventHandlerDelegate(Classname.UpdateMyGlyphEvent));
            Lua.get_Events().AttachEvent("GLYPH_ADDED", new LuaEventHandlerDelegate(Classname.UpdateMyGlyphEvent));
            Lua.get_Events().AttachEvent("GLYPH_UPDATED", new LuaEventHandlerDelegate(Classname.UpdateMyGlyphEvent));
            Lua.get_Events().AttachEvent("GLYPH_REMOVED", new LuaEventHandlerDelegate(Classname.UpdateMyGlyphEvent));
            Chat.add_NeutralBattleground(new Chat.ChatMessageHandlerEx<Chat.ChatSimpleMessageEventArgs>(Classname.ChatFilter));
            Chat.add_AllianceBattleground(new Chat.ChatMessageHandlerEx<Chat.ChatSimpleMessageEventArgs>(Classname.ChatFilter));
            Chat.add_HordeBattleground(new Chat.ChatMessageHandlerEx<Chat.ChatSimpleMessageEventArgs>(Classname.ChatFilter));
            BotEvents.add_OnBotStarted(new BotEvents.OnBotStartDelegate(Classname.OnBotStartedEvent));
            PetSpells.Clear();
            this.PreBuffSelector();
            this.RotationSelector();
            this.RestSelector();
            this.DeathSelector();
            THSettings.Instance.UpdateStatus = true;
            if (!LoginCheckVal)
            {
                Styx.Common.Logging.Write("Please Log In.");
                this.OnButtonPress();
            }
        }

        private static void InLineOfSpellSightCacheAdd(WoWUnit unit, int expireMilliseconds = 100)
        {
            if (!InLineOfSpellSightCache.ContainsKey(unit.Guid))
            {
                InLineOfSpellSightCache.Add(unit.Guid, DateTime.Now + TimeSpan.FromMilliseconds((double) expireMilliseconds));
            }
        }

        private static void InLineOfSpellSightCacheClear()
        {
            foreach (ulong num in (from unit in InLineOfSpellSightCache
                where unit.Value < DateTime.Now
                select unit.Key).ToList<ulong>())
            {
                InLineOfSpellSightCache.Remove(num);
            }
        }

        private static bool InLineOfSpellSightCheck(WoWUnit target)
        {
            InLineOfSpellSightCacheClear();
            if ((target != Me) && !InLineOfSpellSightCache.ContainsKey(target.Guid))
            {
                if (!target.InLineOfSpellSight)
                {
                    return false;
                }
                if (Me.get_CurrentMap().IsRaid || Me.get_CurrentMap().IsDungeon)
                {
                    InLineOfSpellSightCacheAdd(target, 300);
                    return true;
                }
                InLineOfSpellSightCacheAdd(target, 100);
            }
            return true;
        }

        private static bool InterruptCheck(WoWUnit unit, double millisecondsleft, bool includeUninterruptable = true)
        {
            return (((((unit != null) && unit.IsValid) && (unit.IsCasting || unit.IsChanneling)) && (includeUninterruptable || unit.CanInterruptCurrentSpellCast)) && (((!unit.IsCasting || !DoNotInterrupt.Contains(unit.CastingSpellId)) && (!unit.IsChanneling || !DoNotInterrupt.Contains(unit.ChanneledCastingSpellId))) && (!unit.IsCasting || (unit.CurrentCastTimeLeft.TotalMilliseconds <= (millisecondsleft + MyLatency)))));
        }

        private static bool Invulnerable(WoWUnit target)
        {
            if (Me.get_CurrentMap().IsRaid)
            {
                return false;
            }
            return target.GetAllAuras().Any<WoWAura>(aura => InvulnerableHS.Contains(aura.SpellId));
        }

        private static bool InvulnerablePhysic(WoWUnit target)
        {
            if (Me.get_CurrentMap().IsRaid)
            {
                return false;
            }
            return UnitHasAura(0x3fe, target);
        }

        private static bool InvulnerableRootandSnare(WoWUnit target)
        {
            if (Me.get_CurrentMap().IsRaid)
            {
                return false;
            }
            return target.GetAllAuras().Any<WoWAura>(aura => InvulnerableRootandSnareHS.Contains(aura.SpellId));
        }

        private static bool InvulnerableSpell(WoWUnit target)
        {
            if (Me.get_CurrentMap().IsRaid)
            {
                return false;
            }
            return target.GetAllAuras().Any<WoWAura>(aura => InvulnerableSpellHS.Contains(aura.SpellId));
        }

        private static bool InvulnerableStun(WoWUnit target)
        {
            if (Me.get_CurrentMap().IsRaid)
            {
                return false;
            }
            return (((target.get_Class() == ((WoWClass) ((uint) WoWClass.Monk))) && (TalentSort(target) > 3)) || target.GetAllAuras().Any<WoWAura>(aura => InvulnerableStunHS.Contains(aura.SpellId)));
        }

        private static bool IsDummy(WoWUnit target)
        {
            if (!BasicCheck(target))
            {
                return false;
            }
            if (((((target.Entry != 0x79aa) && (target.Entry != 0x10637)) && ((target.Entry != 0xb637) && (target.Entry != 0x7f22))) && (((target.Entry != 0x79a8) && (target.Entry != 0x7f1f)) && ((target.Entry != 0x7f9b) && (target.Entry != 0x7f1e)))) && (target.Entry != 0x7f9a))
            {
                return (target.Entry == 0x773f);
            }
            return true;
        }

        private static bool IsEnemy(WoWUnit target)
        {
            if (EnemyListCache.ContainsKey(target.Guid))
            {
                return true;
            }
            if (!FriendListCache.ContainsKey(target.Guid))
            {
                if (IsMyPartyRaidMember(target))
                {
                    if (UnitHasAura("Reshape Life", target) || UnitHasAura("Convert", target))
                    {
                        return true;
                    }
                    FriendListCacheAdd(target, 60);
                    return false;
                }
                if (Me.get_CurrentMap().IsArena || Me.get_CurrentMap().IsBattleground)
                {
                    EnemyListCacheAdd(target, 10);
                    return true;
                }
                if ((!target.IsFriendly && target.Attackable) && !target.IsQuestGiver)
                {
                    EnemyListCacheAdd(target, 10);
                    return true;
                }
                if ((Me.Combat && IsDummy(target)) && Me.IsFacing((WoWObject) target))
                {
                    EnemyListCacheAdd(target, 10);
                    return true;
                }
            }
            return false;
        }

        private static bool IsMoving(WoWUnit target)
        {
            if ((!target.get_MovementInfo().MovingBackward && !target.get_MovementInfo().MovingForward) && !target.get_MovementInfo().MovingStrafeLeft)
            {
                return target.get_MovementInfo().MovingStrafeRight;
            }
            return true;
        }

        private static bool IsMyPartyRaidMember(WoWUnit target)
        {
            if (FriendListCache.ContainsKey(target.Guid))
            {
                return true;
            }
            if (!EnemyListCache.ContainsKey(target.Guid))
            {
                if (NeedHealUnit(target))
                {
                    FriendListCacheAdd(target, 60);
                    return true;
                }
                if (target.IsPlayer)
                {
                    WoWPlayer player = target as WoWPlayer;
                    if ((player != null) && ((player == Me) || player.IsInMyPartyOrRaid))
                    {
                        FriendListCacheAdd(target, 60);
                        return true;
                    }
                }
                else
                {
                    WoWPlayer player2 = target.get_CreatedByUnit() as WoWPlayer;
                    if ((player2 != null) && ((player2 == Me) || player2.IsInMyPartyOrRaid))
                    {
                        FriendListCacheAdd(target, 60);
                        return true;
                    }
                }
            }
            return false;
        }

        private static bool IsTank(WoWUnit target)
        {
            return (((target.Entry == 0x11a1a) || UnitHasAura("Vengeance", target)) || (from unit in GroupMembers
                where unit.ToPlayer() == target
                select unit).Any<WoWPartyMember>(unit => ((unit.get_Role() & ((WoWPartyMember.GroupRole) ((int) WoWPartyMember.GroupRole.Tank))) != ((WoWPartyMember.GroupRole) ((int) WoWPartyMember.GroupRole.None)))));
        }

        private static void ItemsCooldownCacheAdd(WoWItem Item, DateTime CooldownBack)
        {
            ItemsCooldownCache.Add(Item, CooldownBack);
        }

        private static void ItemsCooldownCacheClear()
        {
            foreach (WoWItem item in (from unit in ItemsCooldownCache
                where unit.Value <= DateTime.Now
                select unit.Key).ToList<WoWItem>())
            {
                ItemsCooldownCache.Remove(item);
            }
        }

        private static void LichborneFearVoid()
        {
            if ((THSettings.Instance.LichborneFear && ((BreakCCLast + TimeSpan.FromMilliseconds(2000.0)) < DateTime.Now)) && (DebuffFearDuration((WoWUnit) Me, (double) THSettings.Instance.LichborneFearDuration) && CanCastCheck("Lichborne", false)))
            {
                BreakCCLast = DateTime.Now;
                CastSpell("Lichborne", (WoWUnit) Me, "LichborneFear");
            }
        }

        private static Composite LichborneHeal()
        {
            Composite[] compositeArray = new Composite[] { (Composite) new Decorator(ret => (((THSettings.Instance.LichborneHeal && (Me.HealthPercent <= THSettings.Instance.LichborneHealHP)) && (Me.Combat && (PlayerRunicPower() >= 40.0))) && !MeHasAura("Lichborne")) && CanCastCheck("Lichborne", true), (Composite) new Styx.TreeSharp.Action(delegate (object ret) {
                CastSpell("Lichborne", (WoWUnit) Me, "LichborneHeal");
                return (RunStatus) RunStatus.Failure;
            })), (Composite) new Decorator(ret => ((THSettings.Instance.LichborneHeal && (Me.HealthPercent <= THSettings.Instance.LichborneHealHP)) && (Me.Combat && MeHasAura("Lichborne"))) && CanCastCheck("Death Coil", false), (Composite) new Styx.TreeSharp.Action(delegate (object ret) {
                CastSpell("Death Coil", (WoWUnit) Me, "LichborneHeal - Death Coil");
                return (RunStatus) RunStatus.Failure;
            })) };
            return (Composite) new PrioritySelector(compositeArray);
        }

        private static Composite LoginCheck()
        {
            return (Composite) new Decorator(ret => !LoginCheckVal, (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                Styx.Common.Logging.Write("Please Click Class Config to Login.");
                return (RunStatus) RunStatus.Success;
            }));
        }

        private static Composite MainRotation()
        {
            Composite[] compositeArray = new Composite[] { LoginCheck(), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                if ((LastWriteDebug < DateTime.Now) && (GetAsyncKeyState(Keys.F10) != 0))
                {
                    LastWriteDebug = DateTime.Now + TimeSpan.FromSeconds(5.0);
                    Styx.Common.Logging.Write("=============================");
                    Styx.Common.Logging.Write("SpellsCooldownCache");
                    object[] args = new object[] { (DateTime.Now + SpellManager.GlobalCooldownLeft).ToString("ss:fff"), DateTime.Now.ToString("ss:fff") };
                    Styx.Common.Logging.Write("{1} GCDBack {0}", args);
                    foreach (KeyValuePair<string, DateTime> pair in SpellsCooldownCache)
                    {
                        Styx.Common.Logging.Write("{2}: {0} - {1}", new object[] { pair.Key, pair.Value.ToString("ss:fff"), DateTime.Now.ToString("ss:fff") });
                    }
                    Styx.Common.Logging.Write("=============================");
                }
                if (GetAsyncKeyState(Keys.F9) != 0)
                {
                    Styx.Common.Logging.Write("=============================");
                    object[] objArray3 = new object[1];
                    TimeSpan span = (TimeSpan) (DateTime.Now - LastRotationTime);
                    objArray3[0] = span.TotalMilliseconds;
                    Styx.Common.Logging.Write("LastRotationTime take {0} ms", objArray3);
                    LastRotationTime = DateTime.Now;
                    Styx.Common.Logging.Write("=============================");
                }
                if ((LastWriteDebug < DateTime.Now) && (GetAsyncKeyState(Keys.F8) != 0))
                {
                    int num = 1;
                    Styx.Common.Logging.Write("=============================");
                    num = 1;
                    Styx.Common.Logging.Write("NearbyFriendlyPlayers");
                    foreach (WoWUnit unit in NearbyFriendlyPlayers)
                    {
                        Styx.Common.Logging.Write(num + ". " + unit.SafeName);
                        num++;
                    }
                    Styx.Common.Logging.Write("=============================");
                    num = 1;
                    Styx.Common.Logging.Write("NearbyFriendlyUnits");
                    foreach (WoWUnit unit2 in NearbyFriendlyUnits)
                    {
                        Styx.Common.Logging.Write(num + ". " + unit2.SafeName);
                        num++;
                    }
                    Styx.Common.Logging.Write("=============================");
                    num = 1;
                    Styx.Common.Logging.Write("FarFriendlyPlayers");
                    foreach (WoWUnit unit3 in FarFriendlyPlayers)
                    {
                        Styx.Common.Logging.Write(num + ". " + unit3.SafeName);
                        num++;
                    }
                    Styx.Common.Logging.Write("=============================");
                    num = 1;
                    Styx.Common.Logging.Write("FarFriendlyUnits");
                    foreach (WoWUnit unit4 in FarFriendlyUnits)
                    {
                        Styx.Common.Logging.Write(num + ". " + unit4.SafeName);
                        num++;
                    }
                    Styx.Common.Logging.Write("=============================");
                    num = 1;
                    Styx.Common.Logging.Write("NearbyUnFriendlyPlayers");
                    foreach (WoWUnit unit5 in NearbyUnFriendlyPlayers)
                    {
                        Styx.Common.Logging.Write(num + ". " + unit5.SafeName);
                        num++;
                    }
                    Styx.Common.Logging.Write("=============================");
                    num = 1;
                    Styx.Common.Logging.Write("NearbyUnFriendlyUnits");
                    foreach (WoWUnit unit6 in NearbyUnFriendlyUnits)
                    {
                        Styx.Common.Logging.Write(num + ". " + unit6.SafeName);
                        num++;
                    }
                    Styx.Common.Logging.Write("=============================");
                    num = 1;
                    Styx.Common.Logging.Write("FarUnFriendlyPlayers");
                    foreach (WoWUnit unit7 in FarUnFriendlyPlayers)
                    {
                        Styx.Common.Logging.Write(num + ". " + unit7.SafeName);
                        num++;
                    }
                    Styx.Common.Logging.Write("=============================");
                    num = 1;
                    Styx.Common.Logging.Write("FarUnFriendlyUnits");
                    foreach (WoWUnit unit8 in FarUnFriendlyUnits)
                    {
                        Styx.Common.Logging.Write(num + ". " + unit8.SafeName);
                        num++;
                    }
                }
                if ((LastWriteDebug < DateTime.Now) && (GetAsyncKeyState(Keys.F7) != 0))
                {
                    LastWriteDebug = DateTime.Now + TimeSpan.FromSeconds(5.0);
                    Styx.Common.Logging.Write("=============================");
                    foreach (WoWAura aura in Me.GetAllAuras())
                    {
                        Styx.Common.Logging.Write("{0} {1} {2}", new object[] { aura.Name, aura.SpellId, aura.get_ApplyAuraType() });
                    }
                    Styx.Common.Logging.Write("=============================");
                    if (BasicCheck(Me.get_CurrentTarget()))
                    {
                        Styx.Common.Logging.Write("Me.CurrentTarget.GetAllAuras()");
                        foreach (WoWAura aura2 in Me.get_CurrentTarget().GetAllAuras())
                        {
                            Styx.Common.Logging.Write("{0} {1} {2}", new object[] { aura2.Name, aura2.SpellId, aura2.get_ApplyAuraType() });
                        }
                        Styx.Common.Logging.Write("=============================");
                    }
                }
                CurrentTargetCheck();
                return (RunStatus) RunStatus.Failure;
            }), Hold(), GetUnits(), (Composite) new Decorator(ret => THSettings.Instance.Pause, (Composite) new Styx.TreeSharp.Action(param0 => (RunStatus) RunStatus.Success)), (Composite) new Decorator(ret => THSettings.Instance.UpdateStatus, (Composite) new Styx.TreeSharp.Action(param0 => (RunStatus) RunStatus.Success)), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                if (((((!IsOverrideModeOn && (GetAsyncKeyState(Keys.LButton) < 0)) && (GetAsyncKeyState(Keys.RButton) < 0)) || ((GetAsyncKeyState(IndexToKeys(THSettings.Instance.StrafleLeft)) < 0) && (IndexToKeys(THSettings.Instance.StrafleLeft) != Keys.None))) || (((GetAsyncKeyState(IndexToKeys(THSettings.Instance.Forward)) < 0) && (IndexToKeys(THSettings.Instance.Forward) != Keys.None)) || ((GetAsyncKeyState(IndexToKeys(THSettings.Instance.StrafleRight)) < 0) && (IndexToKeys(THSettings.Instance.StrafleRight) != Keys.None)))) || ((((GetAsyncKeyState(IndexToKeys(THSettings.Instance.TurnLeft)) < 0) && (IndexToKeys(THSettings.Instance.TurnLeft) != Keys.None)) || ((GetAsyncKeyState(IndexToKeys(THSettings.Instance.Backward)) < 0) && (IndexToKeys(THSettings.Instance.Backward) != Keys.None))) || ((GetAsyncKeyState(IndexToKeys(THSettings.Instance.TurnRight)) < 0) && (IndexToKeys(THSettings.Instance.TurnRight) != Keys.None))))
                {
                    IsOverrideModeOn = true;
                }
                if ((IsOverrideModeOn && ((GetAsyncKeyState(Keys.LButton) >= 0) || (GetAsyncKeyState(Keys.RButton) >= 0))) && ((((GetAsyncKeyState(IndexToKeys(THSettings.Instance.StrafleLeft)) >= 0) && (GetAsyncKeyState(IndexToKeys(THSettings.Instance.Forward)) >= 0)) && ((GetAsyncKeyState(IndexToKeys(THSettings.Instance.StrafleRight)) >= 0) && (GetAsyncKeyState(IndexToKeys(THSettings.Instance.TurnLeft)) >= 0))) && ((GetAsyncKeyState(IndexToKeys(THSettings.Instance.Backward)) >= 0) && (GetAsyncKeyState(IndexToKeys(THSettings.Instance.TurnRight)) >= 0))))
                {
                    IsOverrideModeOn = false;
                }
                if (((Me.get_CurrentTarget() != null) && Me.get_CurrentTarget().IsValid) && (MyLastTarget != Me.get_CurrentTarget()))
                {
                    MyLastTarget = Me.get_CurrentTarget();
                }
                if (((Me.get_CurrentTarget() != null) && !Me.get_CurrentTarget().IsPlayer) && (!Me.get_CurrentTarget().IsAlive && Me.Combat))
                {
                    Lua.DoString("RunMacroText(\"/cleartarget\")", "WoW.lua");
                }
                if ((Me.get_CurrentTarget() != null) && Blacklist.Contains(Me.get_CurrentTarget().Guid, ((BlacklistFlags) BlacklistFlags.Pull) | (((BlacklistFlags) BlacklistFlags.Interact) | (((BlacklistFlags) BlacklistFlags.Node) | (((BlacklistFlags) BlacklistFlags.Combat) | ((BlacklistFlags) BlacklistFlags.Loot))))))
                {
                    Lua.DoString("RunMacroText(\"/cleartarget\")", "WoW.lua");
                }
                return (RunStatus) RunStatus.Failure;
            }), SetAutoAttack(), UseRacial(), UseTrinket(), UseProfession(), (Composite) new Decorator(ret => (UseSpecialization == 2) && !Me.Mounted, FrostRotation()), (Composite) new Decorator(ret => (UseSpecialization == 1) && !Me.Mounted, BloodRotation()), (Composite) new Decorator(ret => (UseSpecialization == 3) && !Me.Mounted, UnholyRotation()), Dismount() };
            return (Composite) new PrioritySelector(compositeArray);
        }

        private static bool MeHasAura(int auraID)
        {
            return Me.GetAllAuras().Any<WoWAura>(aura => (aura.SpellId == auraID));
        }

        private static bool MeHasAura(string auraName)
        {
            return Me.GetAllAuras().Any<WoWAura>(aura => (aura.Name == auraName));
        }

        private static void MindFreezeVoid()
        {
            if ((THSettings.Instance.MindFreezeInterrupt && ((LastInterrupt + TimeSpan.FromMilliseconds(1000.0)) < DateTime.Now)) && (CanCastCheck("Mind Freeze", true) && GetUnitMindFreezeInterrupt()))
            {
                if (Me.IsCasting)
                {
                    SpellManager.StopCasting();
                }
                SafelyFacingTarget(UnitInterrupt);
                if ((UnitInterrupt.IsCasting && (UnitInterrupt.CurrentCastTimeLeft.TotalMilliseconds > (MyLatency + 50.0))) || UnitInterrupt.IsChanneling)
                {
                    CastSpell("Mind Freeze", UnitInterrupt, "MindFreezeVoid");
                    LastInterrupt = DateTime.Now;
                }
            }
        }

        public Composite MovementMoveBehind(UnitSelectionDelegate toUnit)
        {
            return (Composite) new Decorator(delegate (object ret) {
                if ((((!THSettings.Instance.AutoMove || IsOverrideModeOn) || (Me.IsCasting || (toUnit == null))) || (((toUnit(ret) == null) || (toUnit(ret) == Me)) || (!toUnit(ret).IsAlive || (GetDistance(toUnit(ret)) > 5f)))) || Me.IsBehind(toUnit(ret)))
                {
                    return false;
                }
                return toUnit(ret).IsPlayer || ((!toUnit(ret).IsPlayer && (toUnit(ret).get_CurrentTarget() != Me)) && toUnit(ret).Combat);
            }, (Composite) new Styx.TreeSharp.Action(delegate (object ret) {
                Navigator.MoveTo(toUnit(ret).get_Location().RayCast(toUnit(ret).Rotation + WoWMathHelper.DegreesToRadians(150f), 3f));
                return (RunStatus) RunStatus.Failure;
            }));
        }

        private static Composite MovementMoveStop(UnitSelectionDelegate toUnit, double range)
        {
            return (Composite) new Decorator(ret => ((((THSettings.Instance.AutoMove && !IsOverrideModeOn) && ((toUnit != null) && (toUnit(ret) != null))) && (((toUnit(ret) != Me) && toUnit(ret).IsAlive) && (IsMoving((WoWUnit) Me) && IsEnemy(toUnit(ret))))) && (GetDistance(toUnit(ret)) <= range)) && InLineOfSpellSightCheck(toUnit(ret)), (Composite) new Styx.TreeSharp.Action(delegate (object ret) {
                Navigator.get_PlayerMover().MoveStop();
                return (RunStatus) RunStatus.Failure;
            }));
        }

        private static Composite MovementMoveToLoS(UnitSelectionDelegate toUnit)
        {
            return (Composite) new Decorator(delegate (object ret) {
                if (((!THSettings.Instance.AutoMove || IsOverrideModeOn) || (Me.IsCasting || (toUnit == null))) || (((toUnit(ret) == null) || (toUnit(ret) == Me)) || (!toUnit(ret).IsAlive || !IsEnemy(toUnit(ret)))))
                {
                    return false;
                }
                if (GetDistance(toUnit(ret)) <= 30f)
                {
                    return !InLineOfSpellSightCheck(toUnit(ret));
                }
                return true;
            }, (Composite) new Styx.TreeSharp.Action(delegate (object ret) {
                Navigator.MoveTo(toUnit(ret).get_Location());
                return (RunStatus) RunStatus.Failure;
            }));
        }

        private static Composite MovementMoveToMelee(UnitSelectionDelegate toUnit)
        {
            return (Composite) new Decorator(ret => (((THSettings.Instance.AutoMove && !IsOverrideModeOn) && (!Me.IsCasting && (toUnit != null))) && (((toUnit(ret) != null) && (toUnit(ret) != Me)) && (toUnit(ret).IsAlive && IsEnemy(toUnit(ret))))) && (GetDistance(toUnit(ret)) > 3f), (Composite) new Styx.TreeSharp.Action(delegate (object ret) {
                Navigator.MoveTo(toUnit(ret).get_Location());
                return (RunStatus) RunStatus.Failure;
            }));
        }

        private static bool MyAura(int auraID, WoWUnit target)
        {
            return target.GetAllAuras().Any<WoWAura>(aura => ((aura.SpellId == auraID) && (aura.CreatorGuid == Me.Guid)));
        }

        private static bool MyAura(string auraName, WoWUnit target)
        {
            return target.GetAllAuras().Any<WoWAura>(aura => ((aura.Name == auraName) && (aura.CreatorGuid == Me.Guid)));
        }

        private static double MyAuraStackCount(int auraID, WoWUnit target)
        {
            return (double) (from aura in target.GetAllAuras()
                where (aura.SpellId == auraID) && (aura.CreatorGuid == Me.Guid)
                select aura.StackCount).FirstOrDefault<uint>();
        }

        private static double MyAuraStackCount(string auraName, WoWUnit target)
        {
            return (double) (from aura in target.GetAllAuras()
                where (aura.Name == auraName) && (aura.CreatorGuid == Me.Guid)
                select aura.StackCount).FirstOrDefault<uint>();
        }

        private static double MyAuraTimeLeft(int auraID, WoWUnit target)
        {
            return (from aura in target.GetAllAuras()
                where (aura.SpellId == auraID) && (aura.CreatorGuid == Me.Guid)
                select aura.TimeLeft.TotalMilliseconds).FirstOrDefault<double>();
        }

        private static double MyAuraTimeLeft(string auraName, WoWUnit target)
        {
            return (from aura in target.GetAllAuras()
                where (aura.Name == auraName) && (aura.CreatorGuid == Me.Guid)
                select aura.TimeLeft.TotalMilliseconds).FirstOrDefault<double>();
        }

        private static int MyTotalActiveRune()
        {
            return (((Me.BloodRuneCount + Me.FrostRuneCount) + Me.UnholyRuneCount) + Me.DeathRuneCount);
        }

        private static Composite NecroticStrikeStack()
        {
            return (Composite) new Decorator(delegate (object ret) {
                if (((!THSettings.Instance.NecroticStrikeStack || !Me.Combat) || (!CurrentTargetAttackable(5.0, false, false) || !FacingOverride(Me.get_CurrentTarget()))) || (!NecroticStrikeSWReset() || (!NecroticStrikeSW.IsRunning && (Me.DeathRuneCount < THSettings.Instance.NecroticStrikeDeathRuneNumber))))
                {
                    return false;
                }
                return CanCastCheck("Necrotic Strike", false);
            }, (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SafelyFacingTarget(Me.get_CurrentTarget());
                if (THSettings.Instance.NecroticStrikeStack && !NecroticStrikeSW.IsRunning)
                {
                    NecroticStrikeSW.Reset();
                    NecroticStrikeSW.Start();
                }
                if (THSettings.Instance.NecroticStrikeStackBurst && !Burst)
                {
                    Burst = true;
                    BurstLast = DateTime.Now.AddSeconds(15.0);
                    Styx.Common.Logging.Write("Activate Burst Mode on Necrotic Unlease");
                }
                CastSpell("Necrotic Strike", Me.get_CurrentTarget(), "NecroticStrikeStack");
            }));
        }

        private static Composite NecroticStrikeStackMax()
        {
            return (Composite) new Decorator(delegate (object ret) {
                if (((!THSettings.Instance.NecroticStrikeStack || !Me.Combat) || !CurrentTargetAttackable(5.0, false, false)) || ((Me.DeathRuneCount < THSettings.Instance.NecroticStrikeDeathRuneNumber) && ((UseSpecialization != 2) || (Me.DeathRuneCount < 2))))
                {
                    return false;
                }
                return CanCastCheck("Necrotic Strike", false);
            }, (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SafelyFacingTarget(Me.get_CurrentTarget());
                if (THSettings.Instance.NecroticStrikeStack && !NecroticStrikeSW.IsRunning)
                {
                    NecroticStrikeSW.Reset();
                    NecroticStrikeSW.Start();
                }
                if (THSettings.Instance.NecroticStrikeStackBurst && !Burst)
                {
                    Burst = true;
                    BurstLast = DateTime.Now.AddSeconds(15.0);
                    Styx.Common.Logging.Write("Activate Burst Mode on Necrotic Unlease");
                }
                CastSpell("Necrotic Strike", Me.get_CurrentTarget(), "NecroticStrikeStackMax");
            }));
        }

        private static bool NecroticStrikeSWReset()
        {
            if (((THSettings.Instance.NecroticStrikeStack && (UseSpecialization == 3)) && (NecroticStrikeSW.IsRunning && (NecroticStrikeSW.ElapsedMilliseconds > 0x2710L))) && (GetRuneSlot() && (DeathRuneSlot < 1)))
            {
                NecroticStrikeSW.Stop();
                NecroticStrikeSW.Reset();
            }
            if (((THSettings.Instance.NecroticStrikeStack && (UseSpecialization != 3)) && (NecroticStrikeSW.IsRunning && (NecroticStrikeSW.ElapsedMilliseconds > 0xbb8L))) && (Me.DeathRuneCount < 1))
            {
                NecroticStrikeSW.Stop();
                NecroticStrikeSW.Reset();
            }
            return true;
        }

        private static bool NeedHealUnit(WoWUnit target)
        {
            return (NeedHealUnitHS.Contains(target.Entry) && target.IsFriendly);
        }

        private static Composite ObliterateAoE()
        {
            return (Composite) new Decorator(ret => ((THSettings.Instance.Obliterate && (Me.UnholyRuneCount == 2)) && (CurrentTargetAttackable(5.0, false, false) && FacingOverride(Me.get_CurrentTarget()))) && CanCastCheck("Obliterate", false), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Obliterate", Me.get_CurrentTarget(), "ObliterateAoE");
            }));
        }

        private static Composite ObliterateDWKM()
        {
            return (Composite) new Decorator(ret => (((THSettings.Instance.Obliterate && CurrentTargetAttackable(5.0, false, false)) && (MyAura("Frost Fever", Me.get_CurrentTarget()) && MyAura("Blood Plague", Me.get_CurrentTarget()))) && ((!MeHasAura("Freezing Fog") && MeHasAura(0xc7b4)) && (FacingOverride(Me.get_CurrentTarget()) && CanCastCheck("Obliterate", false)))) && !CanCastCheck("Frost Strike", false), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Obliterate", Me.get_CurrentTarget(), "ObliterateDWKM");
            }));
        }

        private static Composite ObliterateDWSimple()
        {
            return (Composite) new Decorator(delegate (object ret) {
                if (((!THSettings.Instance.Obliterate || !CurrentTargetAttackable(5.0, false, false)) || (!MyAura("Frost Fever", Me.get_CurrentTarget()) || !MyAura("Blood Plague", Me.get_CurrentTarget()))) || ((MeHasAura("Freezing Fog") || !FacingOverride(Me.get_CurrentTarget())) || !CanCastCheck("Obliterate", false)))
                {
                    return false;
                }
                return MeHasAura(0xc7b4) || (MeHasAura(0xc7b4) && !CanCastCheck("Frost Strike", false));
            }, (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Obliterate", Me.get_CurrentTarget(), "ObliterateDWSimple");
            }));
        }

        private static Composite ObliterateTH()
        {
            return (Composite) new Decorator(delegate (object ret) {
                if (((!THSettings.Instance.Obliterate || !CurrentTargetAttackable(5.0, false, false)) || (!FacingOverride(Me.get_CurrentTarget()) || (PlayerRunicPower() > 70.0))) || (!CanUseDeathRune() && ((Me.FrostRuneCount <= 0) || (Me.UnholyRuneCount <= 0))))
                {
                    return false;
                }
                return CanCastCheck("Obliterate", false);
            }, (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Obliterate", Me.get_CurrentTarget(), "ObliterateTH");
            }));
        }

        private static Composite ObliterateTHKM()
        {
            return (Composite) new Decorator(ret => (((THSettings.Instance.Obliterate && CurrentTargetAttackable(5.0, false, false)) && (MyAura("Frost Fever", Me.get_CurrentTarget()) && MyAura("Blood Plague", Me.get_CurrentTarget()))) && (MeHasAura(0xc7b4) && FacingOverride(Me.get_CurrentTarget()))) && CanCastCheck("Obliterate", false), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Obliterate", Me.get_CurrentTarget(), "ObliterateTHKM");
            }));
        }

        private static void OnBotStartedEvent(object o)
        {
            if (Me.get_Inventory().get_Equipped().get_Hands() != null)
            {
                Me.get_Inventory().get_Equipped().get_Hands().Name.Contains("Malevolent Gladiator's Scaled Gauntlets");
            }
            Styx.Common.Logging.Write("----------------------------------");
            Styx.Common.Logging.Write("Update Status on Bot Start");
            Styx.Common.Logging.Write("----------------------------------");
            THSettings.Instance.Pause = false;
            THSettings.Instance.UpdateStatus = true;
        }

        public override void OnButtonPress()
        {
            if (LoginCheckVal)
            {
                new THForm().ShowDialog();
            }
            else
            {
                new THLogin().ShowDialog();
            }
        }

        private static Composite Outbreak()
        {
            return (Composite) new Decorator(ret => (((THSettings.Instance.Outbreak && CurrentTargetAttackable(30.0, false, false)) && ((MyAuraTimeLeft("Frost Fever", Me.get_CurrentTarget()) < 2000.0) || (MyAuraTimeLeft("Blood Plague", Me.get_CurrentTarget()) < 2000.0))) && (!InvulnerableSpell(Me.get_CurrentTarget()) && FacingOverride(Me.get_CurrentTarget()))) && CanCastCheck("Outbreak", false), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                LastFrostFeverDebuff = DateTime.Now;
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Outbreak", Me.get_CurrentTarget(), "");
            }));
        }

        private static Composite PathofFrost()
        {
            return (Composite) new Decorator(ret => ((((THSettings.Instance.AutoPathofFrost && (LastPathofFrost.AddSeconds(10.0) < DateTime.Now)) && !Me.Combat) && (Me.Mounted || Me.IsSwimming)) && !MeHasAura("Path of Frost")) && CanCastCheck("Path of Frost", false), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Path of Frost", (WoWUnit) Me, "");
                LastPathofFrost = DateTime.Now;
            }));
        }

        private static Composite Pestilence()
        {
            return (Composite) new Decorator(ret => (((THSettings.Instance.Pestilence && (LastSpreadDiseases < DateTime.Now)) && (!SpellManager.HasSpell("Roiling Blood") && CanCastCheck("Pestilence", false))) && (!HasEnemyNearGotCCBreakonDamge(Me.get_CurrentTarget(), (float) (10 + GlyphprivateofPestilenceBonus)) && HasEnemyDontHaveBloodPlagueorFrostFever())) && GetBestPestilenceTarget(), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SafelyFacingTarget(BestPestilenceTarget);
                CastSpell("Pestilence", BestPestilenceTarget, "");
                LastSpreadDiseases = DateTime.Now + TimeSpan.FromMilliseconds(2000.0);
            }));
        }

        private static Composite PetAttack()
        {
            return (Composite) new Decorator(ret => ((((THSettings.Instance.PetAttack && ((HoldPetAction + TimeSpan.FromMilliseconds(4000.0)) < DateTime.Now)) && (CurrentTargetAttackableNoLoS(40.0) && Me.GotAlivePet)) && ((Me.get_Pet().HealthPercent >= 30.0) || (Me.get_Pet().Distance < 10.0))) && (Me.get_CurrentTarget().ZDiff < 10f)) && (((Me.get_Pet().get_CurrentTarget() == null) || ((!Me.get_CurrentMap().IsArena && (Me.get_Pet().get_CurrentTarget() != null)) && (Me.get_Pet().get_CurrentTarget() != Me.get_CurrentTarget()))) || (((Me.get_CurrentMap().IsArena && (Me.get_Pet().get_CurrentTarget() != null)) && (Me.get_Pet().get_CurrentTarget() != Me.get_CurrentTarget())) && !Me.get_Pet().get_CurrentTarget().IsPlayer)), (Composite) new Styx.TreeSharp.Action(delegate (object ret) {
                Styx.Common.Logging.Write("PetAttack");
                Lua.DoString("RunMacroText('/petattack');", "WoW.lua");
                return (RunStatus) RunStatus.Failure;
            }));
        }

        private static bool PetCanCastAction(string action)
        {
            WoWPetSpell spell = PetSpells.FirstOrDefault<WoWPetSpell>(p => p.ToString() == action);
            return (((spell != null) && (spell.get_Spell() != null)) && !spell.get_Spell().Cooldown);
        }

        private static void PetCastAction(string action, WoWUnit on)
        {
            WoWUnit unit = null;
            WoWPetSpell spell = PetSpells.FirstOrDefault<WoWPetSpell>(p => p.ToString() == action);
            if (spell == null)
            {
                Styx.Common.Logging.Write("Your pet don't have " + action);
            }
            else if ((Me.get_CurrentTarget() != null) && (on == Me.get_CurrentTarget()))
            {
                Lua.DoString("CastPetAction({0}, 'target')", new object[] { spell.ActionBarIndex + 1 });
            }
            else if ((Me.get_CurrentTarget() != null) && (on == Me))
            {
                Lua.DoString("CastPetAction({0}, 'player')", new object[] { spell.ActionBarIndex + 1 });
            }
            else if ((Me.get_CurrentTarget() != null) && (on == Me.get_Pet()))
            {
                Lua.DoString("CastPetAction({0}, 'pet')", new object[] { spell.ActionBarIndex + 1 });
            }
            else
            {
                if (Me.get_FocusedUnit() != null)
                {
                    unit = Me.get_FocusedUnit();
                }
                StyxWoW.get_Me().SetFocus((WoWObject) on);
                Lua.DoString("CastPetAction({0}, 'focus')", new object[] { spell.ActionBarIndex + 1 });
                if (unit != null)
                {
                    StyxWoW.get_Me().SetFocus((WoWObject) unit);
                }
                else
                {
                    StyxWoW.get_Me().SetFocus((ulong) 0L);
                }
            }
        }

        private static Composite PetFollow()
        {
            return (Composite) new Decorator(ret => ((THSettings.Instance.Follow && ((HoldPetAction + TimeSpan.FromMilliseconds(2000.0)) < DateTime.Now)) && Me.GotAlivePet) && (Me.get_Pet().Distance > THSettings.Instance.FollowDistance), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                HoldPetAction = DateTime.Now;
                Lua.DoString("RunMacroText('/PetFollow');", "WoW.lua");
                return (RunStatus) RunStatus.Failure;
            }));
        }

        private TimeSpan PetGetSpellCooldown(string spellname)
        {
            WoWPetSpell spell = PetSpells.FirstOrDefault<WoWPetSpell>(p => p.ToString() == spellname);
            if (spell == null)
            {
                return TimeSpan.FromMilliseconds(0.0);
            }
            return spell.get_Spell().CooldownTimeLeft;
        }

        private static void PetGnawInterruptVoid()
        {
            if ((((THSettings.Instance.GnawInterrupt && ((LastInterrupt + TimeSpan.FromMilliseconds(1000.0)) < DateTime.Now)) && (Me.GotAlivePet && GetUnitPetGnawInterrupt())) && PetCanCastAction("Gnaw")) && ((UnitInterrupt.IsCasting && (UnitInterrupt.CurrentCastTimeLeft.TotalMilliseconds > (MyLatency + 50.0))) || UnitInterrupt.IsChanneling))
            {
                Styx.Common.Logging.Write((Styx.Common.LogLevel) Styx.Common.LogLevel.Diagnostic, "Gnaw UnitInterrupt");
                PetCastAction("Gnaw", UnitInterrupt);
                HoldPetAction = DateTime.Now;
                LastInterrupt = DateTime.Now;
            }
            if (((THSettings.Instance.ChargeInterrupt && ((LastInterrupt + TimeSpan.FromMilliseconds(1000.0)) < DateTime.Now)) && (Me.GotAlivePet && UnitHasAura("Dark Transformation", Me.get_Pet()))) && ((PetCanCastAction("Leap") && GetUnitPetChargeInterrupt()) && UnitInterrupt.IsCasting))
            {
                Styx.Common.Logging.Write((Styx.Common.LogLevel) Styx.Common.LogLevel.Diagnostic, "Leap Charge UnitInterrupt");
                PetCastAction("Leap", UnitInterrupt);
                HoldPetAction = DateTime.Now;
                LastInterrupt = DateTime.Now;
            }
        }

        private static bool PetHasSpell(string spellname)
        {
            if (!Me.GotAlivePet)
            {
                return false;
            }
            return (PetSpells.FirstOrDefault<WoWPetSpell>(p => (p.ToString() == spellname)) != null);
        }

        private static Composite PetLeap()
        {
            return (Composite) new Decorator(ret => ((((THSettings.Instance.LeapRange && ((HoldPetAction + TimeSpan.FromMilliseconds(3000.0)) < DateTime.Now)) && (Me.GotAlivePet && CurrentTargetAttackableNoLoS(40.0))) && (((Me.get_Pet().HealthPercent >= 30.0) && (Me.get_Pet().get_Location().Distance(Me.get_CurrentTarget().get_Location()) > 5f)) && ((Me.get_Pet().get_Location().Distance(Me.get_CurrentTarget().get_Location()) < THSettings.Instance.LeapRangeDist) && (Me.get_Pet().ZDiff < 20f)))) && PetCanCastAction("Leap")) && AttackableNoLoS(Me.get_CurrentTarget(), 40), (Composite) new Styx.TreeSharp.Action(delegate (object ret) {
                Styx.Common.Logging.Write("LeapRange");
                PetCastAction("Leap", Me.get_CurrentTarget());
                return (RunStatus) RunStatus.Failure;
            }));
        }

        private static void PetSpellsUpdate()
        {
            if (Me.GotAlivePet)
            {
                Styx.Common.Logging.Write("PetSpellsUpdate");
                Styx.Common.Logging.Write("Toggle Pet Gnaw and Leap Autocast Off");
                Styx.Common.Logging.Write("Better let Combat Routine handle it.");
                Lua.DoString("RunMacroText('/petautocastoff Gnaw');", "WoW.lua");
                Lua.DoString("RunMacroText('/petautocastoff Leap');", "WoW.lua");
                Lua.DoString("RunMacroText('/petautocaston Claw');", "WoW.lua");
                PetSpells.Clear();
                PetSpells.AddRange(Me.get_PetSpells());
                Styx.Common.Logging.Write("Your Current Pet Action Bar:");
                foreach (WoWPetSpell spell in PetSpells)
                {
                    if (spell.get_Action().ToString() != "None")
                    {
                        Styx.Common.Logging.Write(spell.get_Action().ToString());
                    }
                    else
                    {
                        if (spell.get_Spell() != null)
                        {
                            Styx.Common.Logging.Write(spell.get_Spell().ToString());
                            continue;
                        }
                        Styx.Common.Logging.Write(spell.get_Stance().ToString());
                    }
                }
            }
        }

        private static void PetStunEnemyHPVoid()
        {
            if ((THSettings.Instance.GnawStunEnemy && Me.GotAlivePet) && (PetCanCastAction("Gnaw") && GetUnitPetGnawEnemyLowHP()))
            {
                Styx.Common.Logging.Write((Styx.Common.LogLevel) Styx.Common.LogLevel.Diagnostic, "Gnaw UnitPetStunEnemyLowHP");
                PetCastAction("Gnaw", UnitPetStunEnemyLowHP);
                HoldPetAction = DateTime.Now;
            }
            if (((THSettings.Instance.ChargeStunEnemy && Me.GotAlivePet) && (UnitHasAura("Dark Transformation", Me.get_Pet()) && PetCanCastAction("Leap"))) && GetUnitPetChargeEnemyLowHP())
            {
                Styx.Common.Logging.Write((Styx.Common.LogLevel) Styx.Common.LogLevel.Diagnostic, "Leap Charge UnitPetStunEnemyLowHP");
                PetCastAction("Leap", UnitPetStunEnemyLowHP);
                HoldPetAction = DateTime.Now;
            }
        }

        private static void PetStunFriendHPVoid()
        {
            if ((THSettings.Instance.GnawStunFriend && Me.GotAlivePet) && (PetCanCastAction("Gnaw") && GetUnitPetGnawSaveFriendLowHP()))
            {
                Styx.Common.Logging.Write((Styx.Common.LogLevel) Styx.Common.LogLevel.Diagnostic, "Gnaw UnitPetStunSaveFriendLowHP");
                PetCastAction("Gnaw", UnitPetStunSaveFriendLowHP);
                HoldPetAction = DateTime.Now;
            }
            if (((THSettings.Instance.ChargeStunEnemy && Me.GotAlivePet) && (UnitHasAura("Dark Transformation", Me.get_Pet()) && PetCanCastAction("Leap"))) && GetUnitPetChargeSaveFriendLowHP())
            {
                Styx.Common.Logging.Write((Styx.Common.LogLevel) Styx.Common.LogLevel.Diagnostic, "Leap Charge UnitPetStunSaveFriendLowHP");
                PetCastAction("Leap", UnitPetStunSaveFriendLowHP);
                HoldPetAction = DateTime.Now;
            }
        }

        private static Composite PillarofFrost()
        {
            return (Composite) new Decorator(delegate (object ret) {
                if (!CurrentTargetAttackable(5.0, false, false) || ((((THSettings.Instance.PillarofFrost != 1) && ((THSettings.Instance.PillarofFrost != 2) || !Me.get_CurrentTarget().IsBoss)) && ((THSettings.Instance.PillarofFrost != 3) || !Burst)) && ((THSettings.Instance.PillarofFrost != 4) || (Me.get_CurrentTarget().HealthPercent > THSettings.Instance.PillarofFrostPercent))))
                {
                    return false;
                }
                return CanCastCheck("Pillar of Frost", true);
            }, (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Pillar of Frost", (WoWUnit) Me, "");
                return (RunStatus) RunStatus.Failure;
            }));
        }

        private static Composite PlagueLeech()
        {
            return (Composite) new Decorator(ret => ((((THSettings.Instance.PlagueLeech && ((LastPlagueLeech + TimeSpan.FromMilliseconds(1000.0)) < DateTime.Now)) && (CurrentTargetAttackable(30.0, false, false) && MyAura("Frost Fever", Me.get_CurrentTarget()))) && (MyAura("Blood Plague", Me.get_CurrentTarget()) && (IsDummy(Me.get_CurrentTarget()) || (Me.get_CurrentTarget().CurrentHealth > (Me.CurrentHealth * 0.8))))) && (((MyTotalActiveRune() < 5) && GetRuneSlot()) && (DeathRuneSlot < 4))) && CanCastCheck("Plague Leech", false), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                LastPlagueLeech = DateTime.Now;
                CastSpell("Plague Leech", Me.get_CurrentTarget(), "");
            }));
        }

        private static Composite PlagueStrikeBloodAoE()
        {
            return (Composite) new Decorator(ret => (((THSettings.Instance.PlagueStrike && (LastCastSpell != "Outbreak")) && ((Me.UnholyRuneCount > 1) && CurrentTargetAttackable(5.0, false, false))) && ((FacingOverride(Me.get_CurrentTarget()) && (Me.UnholyRuneCount > 1)) && CanCastCheck("Plague Strike", false))) && !HasEnemyDontHaveBloodPlague(), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Plague Strike", Me.get_CurrentTarget(), "PlagueStrikeBloodAoE");
            }));
        }

        private static Composite PlagueStrikeDebuff()
        {
            return (Composite) new Decorator(ret => ((((THSettings.Instance.PlagueStrike && CurrentTargetAttackable(5.0, false, false)) && FacingOverride(Me.get_CurrentTarget())) && (((MyAuraTimeLeft("Blood Plague", Me.get_CurrentTarget()) < 3000.0) || ((MyAuraTimeLeft("Frost Fever", Me.get_CurrentTarget()) < 3000.0) && SpellManager.HasSpell("Ebon Plaguebringer"))) || !SpellManager.HasSpell("Death Strike"))) && CanCastCheck("Plague Strike", false)) && ((!THSettings.Instance.Outbreak || !SpellManager.HasSpell("Outbreak")) || (SpellManager.HasSpell("Outbreak") && (GetSpellCooldown("Outbreak").TotalMilliseconds > 3000.0))), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Plague Strike", Me.get_CurrentTarget(), "PlagueStrikeDebuff");
            }));
        }

        private static Composite PlagueStrikeFrostAoE()
        {
            return (Composite) new Decorator(ret => ((((THSettings.Instance.PlagueStrike && !IsMoving((WoWUnit) Me)) && CurrentTargetAttackable(5.0, false, false)) && ((Me.get_CurrentTarget().CurrentHealth > (Me.MaxHealth * 0.5)) || IsDummy(Me.get_CurrentTarget()))) && (Me.UnholyRuneCount == 2)) && CanCastCheck("Plague Strike", false), (Composite) new Styx.TreeSharp.Action(delegate (object ret) {
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Plague Strike", Me.get_CurrentTarget(), "PlagueStrikeFrostAoE");
            }));
        }

        private static double PlayerRunicPower()
        {
            try
            {
                return (double) Me.CurrentRunicPower;
            }
            catch
            {
                Styx.Common.Logging.Write("Failed in PlayerRunicPower()");
                return 0.0;
            }
        }

        private Composite PreBuffSelector()
        {
            if (this._preCombatBuffBehavior == null)
            {
                Styx.Common.Logging.Write("Initializing pre-combat buff behaviours.");
                this._preCombatBuffBehavior = (Composite) new PrioritySelector(new Composite[] { MainRotation() });
            }
            return null;
        }

        private static Composite Presence()
        {
            return (Composite) new Decorator(delegate (object ret) {
                if (!THSettings.Instance.AutoPrecence || !THSettings.Instance.FrostPresence)
                {
                    return false;
                }
                return (NeedResetPresence || ((!MeHasAura("Blood Presence") && !MeHasAura("Frost Presence")) && !MeHasAura("Unholy Presence"))) || (THSettings.Instance.LastSavedSpec != GetCurrentSpec());
            }, (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                if (((UseSpecialization == 2) && !MeHasAura("Frost Presence")) && CanCastCheck("Frost Presence", false))
                {
                    CastSpell("Frost Presence", (WoWUnit) Me, "");
                    NeedResetPresence = false;
                }
                if (((UseSpecialization == 1) && !MeHasAura("Blood Presence")) && CanCastCheck("Blood Presence", false))
                {
                    CastSpell("Blood Presence", (WoWUnit) Me, "");
                    NeedResetPresence = false;
                }
                if (((UseSpecialization == 3) && !MeHasAura("Unholy Presence")) && CanCastCheck("Unholy Presence", false))
                {
                    CastSpell("Unholy Presence", (WoWUnit) Me, "");
                    NeedResetPresence = false;
                }
                NeedResetPresence = false;
                return (RunStatus) RunStatus.Failure;
            }));
        }

        public override void Pulse()
        {
            if (StyxWoW.IsInWorld && BasicCheck((WoWUnit) Me))
            {
                if (THSettings.Instance.UpdateStatus)
                {
                    UpdateStatus();
                }
                else
                {
                    GlobalCheck();
                    ReturningFlag();
                    if (!Me.Mounted)
                    {
                        LichborneFearVoid();
                        DeathGripInterruptVoid();
                        MindFreezeVoid();
                        ArcaneTorrentVoid();
                        StrangulateVoid();
                        AsphyxiateVoid();
                        GorefiendsGraspInterruptVoid();
                        PetGnawInterruptVoid();
                        PetStunEnemyHPVoid();
                        PetStunFriendHPVoid();
                        CancelAura(0x5f);
                    }
                    if (((THSettings.Instance.UsePauseKey && (THSettings.Instance.PauseKey != 0)) && ((GetAsyncKeyState(Keys.LControlKey) < 0) && (GetAsyncKeyState(IndexToKeys(THSettings.Instance.PauseKey)) < 0))) && (LastSwitch.AddSeconds(1.0) < DateTime.Now))
                    {
                        if (THSettings.Instance.Pause)
                        {
                            THSettings.Instance.Pause = false;
                            LastSwitch = DateTime.Now;
                            Styx.Common.Logging.Write("Pause Mode is OFF, Hold 1 second Ctrl + " + IndexToKeys(THSettings.Instance.PauseKey) + " to Override bot action.");
                        }
                        else
                        {
                            THSettings.Instance.Pause = true;
                            THSettings.Instance.UpdateStatus = true;
                            LastSwitch = DateTime.Now;
                            Styx.Common.Logging.Write("Pause Mode is ON, Hold 1 second Ctrl + " + IndexToKeys(THSettings.Instance.PauseKey) + " to resume bot action.");
                        }
                    }
                    if (Burst && (BurstLast < DateTime.Now))
                    {
                        Burst = false;
                        Styx.Common.Logging.Write("Burst Mode is OFF");
                    }
                    if (((THSettings.Instance.BurstKey == 1) && !Burst) && (Me.Combat && !DebuffCC((WoWUnit) Me)))
                    {
                        BurstLast = DateTime.Now.AddSeconds(15.0);
                        Styx.Common.Logging.Write("Burst Mode Activated On Cooldown");
                        Burst = true;
                    }
                    if ((((THSettings.Instance.BurstKey == 2) && !Burst) && (Me.Combat && Attackable(Me.get_CurrentTarget(), 15))) && (Me.get_CurrentTarget().IsBoss && !DebuffCC((WoWUnit) Me)))
                    {
                        BurstLast = DateTime.Now.AddSeconds(15.0);
                        Styx.Common.Logging.Write("Burst Mode Activated On Cooldown (Boss Only)");
                        Burst = true;
                    }
                    if ((((THSettings.Instance.BurstKey == 3) && !Burst) && ((MeHasAura("Bloodlust") || MeHasAura("Heroism")) || (MeHasAura("Time Warp") || MeHasAura("Ancient Hysteria")))) && !DebuffCC((WoWUnit) Me))
                    {
                        BurstLast = DateTime.Now.AddSeconds(15.0);
                        Styx.Common.Logging.Write("Burst Mode Activated On Bloodlust/Heroism/Time Warp/Ancient Hysteria");
                        Burst = true;
                    }
                    if (((THSettings.Instance.BurstKey == 4) && !Burst) && DebuffCCDuration((WoWUnit) Me, 3000.0, false))
                    {
                        BurstLast = DateTime.Now.AddSeconds(15.0);
                        Styx.Common.Logging.Write("Burst Mode Activated on Lose Control");
                        Burst = true;
                    }
                    if (((THSettings.Instance.BurstKey == 5) && !Burst) && ((Me.HealthPercent < THSettings.Instance.BurstHP) && !DebuffCC((WoWUnit) Me)))
                    {
                        BurstLast = DateTime.Now.AddSeconds(15.0);
                        Styx.Common.Logging.Write("Burst Mode Activated on My Health Low");
                        Burst = true;
                    }
                    if ((((THSettings.Instance.BurstKey == 6) && !Burst) && (CurrentTargetAttackable(30.0, false, false) && !Me.get_CurrentTarget().IsPet)) && (((Me.HealthPercent > THSettings.Instance.UrgentHeal) && (Me.get_CurrentTarget().HealthPercent < THSettings.Instance.BurstHP)) && !DebuffCC((WoWUnit) Me)))
                    {
                        BurstLast = DateTime.Now.AddSeconds(15.0);
                        Styx.Common.Logging.Write("Burst Mode Activated on Enemy Health Low");
                        Burst = true;
                    }
                    if (((THSettings.Instance.BurstKey > 6) && (GetAsyncKeyState(Keys.LControlKey) < 0)) && ((GetAsyncKeyState(IndexToKeys(THSettings.Instance.BurstKey - 6)) < 0) && (LastSwitch.AddSeconds(1.0) < DateTime.Now)))
                    {
                        if (Burst)
                        {
                            Burst = false;
                            LastSwitch = DateTime.Now;
                            Styx.Common.Logging.Write("Burst Mode is OFF, Hold 1 second Ctrl + " + IndexToKeys(THSettings.Instance.BurstKey - 6) + " to Turn Burst Mode ON.");
                        }
                        else if (!DebuffCC((WoWUnit) Me))
                        {
                            Burst = true;
                            LastSwitch = DateTime.Now;
                            BurstLast = DateTime.Now.AddSeconds(15.0);
                            Styx.Common.Logging.Write("Burst Mode is ON for 15 seconds, Hold 1 second Ctrl + " + IndexToKeys(THSettings.Instance.BurstKey - 6) + " to Turn Burst Mode OFF.");
                        }
                    }
                }
            }
        }

        private static Composite RaiseAlly()
        {
            return (Composite) new Decorator(ret => ((((THSettings.Instance.AutoRaiseAlly && ((GetUnitRaiseAllyLastSearch + TimeSpan.FromMilliseconds(10000.0)) < DateTime.Now)) && Me.Combat) && (Me.get_CurrentMap().IsDungeon || Me.get_CurrentMap().IsRaid)) && ((PlayerRunicPower() >= 30.0) && CanCastCheck("Raise Ally", false))) && GetUnitRaiseAlly(), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Raise Ally", (WoWUnit) UnitRaiseAlly, "RaiseAlly");
            }));
        }

        private static Composite RaiseDead()
        {
            return (Composite) new Decorator(delegate (object ret) {
                if ((((!CurrentTargetAttackable(5.0, false, false) || Me.GotAlivePet) || ((Me.get_Minions().Count != 0) || (Me.CurrentHealth <= THSettings.Instance.UrgentHeal))) || ((Me.get_CurrentTarget().CurrentHealth <= (Me.CurrentHealth * 0.8)) && !IsDummy(Me.get_CurrentTarget()))) || ((((THSettings.Instance.RaiseDead != 1) && ((THSettings.Instance.RaiseDead != 2) || !Me.get_CurrentTarget().IsBoss)) && ((THSettings.Instance.RaiseDead != 3) || !Burst)) && ((THSettings.Instance.RaiseDead != 4) || (Me.get_CurrentTarget().HealthPercent > THSettings.Instance.RaiseDeadPercent))))
                {
                    return false;
                }
                return CanCastCheck("Raise Dead", false);
            }, (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Raise Dead", (WoWUnit) Me, "");
            }));
        }

        private static Composite RaiseDeadUnholy()
        {
            return (Composite) new Decorator(ret => !Me.GotAlivePet && CanCastCheck("Raise Dead", false), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Raise Dead", (WoWUnit) Me, "RaiseDeadUnholy");
            }));
        }

        private static Composite RemorselessWinter()
        {
            return (Composite) new Decorator(ret => ((THSettings.Instance.RemorselessWinter && Me.Combat) && (CurrentTargetAttackable(8.0, false, false) && (Me.HealthPercent <= THSettings.Instance.RemorselessWinterHP))) && CanCastCheck("Remorseless Winter", true), (Composite) new Styx.TreeSharp.Action(delegate (object ret) {
                CastSpell("Remorseless Winter", (WoWUnit) Me, "RemorselessWinterHP");
                return (RunStatus) RunStatus.Failure;
            }));
        }

        private static Composite RemorselessWinterBurst()
        {
            return (Composite) new Decorator(ret => ((THSettings.Instance.RemorselessWinterBurst && Burst) && (Me.Combat && CurrentTargetAttackable(8.0, false, false))) && CanCastCheck("Remorseless Winter", true), (Composite) new Styx.TreeSharp.Action(delegate (object ret) {
                CastSpell("Remorseless Winter", (WoWUnit) Me, "RemorselessWinterBurst");
                return (RunStatus) RunStatus.Failure;
            }));
        }

        private static Composite RemorselessWinterEnemyLowHP()
        {
            return (Composite) new Decorator(ret => ((THSettings.Instance.RemorselessWinterEnemyLow && Me.Combat) && (CurrentTargetAttackable(8.0, false, false) && (Me.get_CurrentTarget().HealthPercent <= THSettings.Instance.RemorselessWinterEnemyLowHP))) && CanCastCheck("Remorseless Winter", true), (Composite) new Styx.TreeSharp.Action(delegate (object ret) {
                LastShield = DateTime.Now;
                CastSpell("Remorseless Winter", (WoWUnit) Me, "RemorselessWinterEnemyLowHP");
                return (RunStatus) RunStatus.Failure;
            }));
        }

        private static Composite RemorselessWinterEnemyNumber()
        {
            return (Composite) new Decorator(ret => ((THSettings.Instance.RemorselessWinterEnemy && Me.Combat) && (CurrentTargetAttackable(8.0, false, false) && CanCastCheck("Remorseless Winter", true))) && (CountEnemyNearNoCC((WoWUnit) Me, 8f) >= THSettings.Instance.RemorselessWinterEnemyNumber), (Composite) new Styx.TreeSharp.Action(delegate (object ret) {
                LastShield = DateTime.Now;
                CastSpell("Remorseless Winter", (WoWUnit) Me, "RemorselessWinterEnemyNumber");
                return (RunStatus) RunStatus.Failure;
            }));
        }

        private static Composite RestRotation()
        {
            return (Composite) new Decorator(ret => ((((THSettings.Instance.UseFood && (Me.HealthPercent <= THSettings.Instance.UseFoodHP)) && (!Me.Combat && !Me.IsDead)) && ((!Me.IsGhost && !IsOverrideModeOn) && (!Me.IsCasting && !Me.IsSwimming))) && !MeHasAura("Food")) && (Consumable.GetBestFood(true) != null), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                Styx.Common.Logging.Write("Using Food");
                if (IsMoving((WoWUnit) Me))
                {
                    WoWMovement.MoveStop();
                }
                Rest.FeedImmediate();
                new WaitContinue(1, ret => false, (Composite) new ActionAlwaysSucceed());
            }));
        }

        private Composite RestSelector()
        {
            if (this._restBehavior == null)
            {
                Styx.Common.Logging.Write("Initializing rest behaviours.");
                this._restBehavior = (Composite) new PrioritySelector(new Composite[] { RestRotation() });
            }
            return null;
        }

        private static void ReturningFlag()
        {
            if (SearchFlagTime >= DateTime.Now)
            {
                WoWGameObject obj2 = ObjectManager.GetObjectsOfType<WoWGameObject>().FirstOrDefault<WoWGameObject>(delegate (WoWGameObject obj) {
                    if (!(obj.Name == "Alliance Flag") && !(obj.Name == "Horde Flag"))
                    {
                        return false;
                    }
                    return obj.Distance <= 15.0;
                });
                if (obj2 != null)
                {
                    if (!IsOverrideModeOn)
                    {
                        Navigator.MoveTo(obj2.get_Location());
                    }
                    Me.SetFacing(obj2.get_Location());
                    obj2.Interact();
                    Styx.Common.Logging.Write("Trying to Return/Pick Up Dropped flag!");
                }
            }
        }

        private Composite RotationSelector()
        {
            if (this._combatBehavior == null)
            {
                Styx.Common.Logging.Write("Initializing combat behaviours.");
                this._combatBehavior = (Composite) new PrioritySelector(new Composite[] { MainRotation() });
            }
            return null;
        }

        private static Composite RuneStrike()
        {
            return (Composite) new Decorator(ret => ((THSettings.Instance.RuneStrike && CurrentTargetAttackable(5.0, false, false)) && (!HoldSpendingRunicPower() && (PlayerRunicPower() >= 50.0))) && CanCastCheck("Rune Strike", false), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Rune Strike", Me.get_CurrentTarget(), "");
            }));
        }

        private static Composite RuneStrikeCap()
        {
            return (Composite) new Decorator(ret => (((THSettings.Instance.RuneStrike && ((LastCap + TimeSpan.FromMilliseconds(2000.0)) < DateTime.Now)) && (CurrentTargetAttackable(5.0, false, false) && (PlayerRunicPower() >= 60.0))) && !HoldSpendingRunicPower()) && CanCastCheck("Rune Strike", false), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                LastCap = DateTime.Now;
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Rune Strike", Me.get_CurrentTarget(), "RuneStrikeCap");
            }));
        }

        private static Composite RuneTap()
        {
            return (Composite) new Decorator(ret => ((THSettings.Instance.RuneTap && Me.Combat) && (CurrentTargetAttackable(30.0, false, false) && (Me.HealthPercent <= THSettings.Instance.RuneTapHP))) && CanCastCheck("Rune Tap", true), (Composite) new Styx.TreeSharp.Action(delegate (object ret) {
                CastSpell("Rune Tap", (WoWUnit) Me, "");
                return (RunStatus) RunStatus.Failure;
            }));
        }

        private static void SafelyFacingTarget(WoWUnit target)
        {
            if ((!IsUsingAFKBot || !IsMoving((WoWUnit) Me)) && ((THSettings.Instance.AutoFace && !IsOverrideModeOn) && !Me.IsSafelyFacing((WoWObject) target)))
            {
                Me.SetFacing(target.get_Location());
                WoWMovement.ConstantFace(target.Guid);
            }
        }

        private static bool SafeUsingCooldown(WoWUnit target)
        {
            if (Me.get_CurrentMap().IsRaid)
            {
                return false;
            }
            return !target.GetAllAuras().Any<WoWAura>(aura => SafeUsingCooldownHS.Contains(aura.SpellId));
        }

        private static Composite ScourgeStrike()
        {
            return (Composite) new Decorator(delegate (object ret) {
                if (((!THSettings.Instance.ScourgeStrike || !CurrentTargetAttackable(5.0, false, false)) || !FacingOverride(Me.get_CurrentTarget())) || (!CanUseDeathRune() && (Me.UnholyRuneCount <= 0)))
                {
                    return false;
                }
                return CanCastCheck("Scourge Strike", false);
            }, (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Scourge Strike", Me.get_CurrentTarget(), "ScourgeStrike");
            }));
        }

        private static Composite ScourgeStrike90()
        {
            return (Composite) new Decorator(delegate (object ret) {
                if (((!THSettings.Instance.ScourgeStrike || !CurrentTargetAttackable(5.0, false, false)) || (!FacingOverride(Me.get_CurrentTarget()) || (PlayerRunicPower() >= 90.0))) || (!CanUseDeathRune() && (Me.UnholyRuneCount <= 0)))
                {
                    return false;
                }
                return CanCastCheck("Scourge Strike", false);
            }, (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Scourge Strike", Me.get_CurrentTarget(), "ScourgeStrike90");
            }));
        }

        private static Composite SetAutoAttack()
        {
            return (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                if (((Me.get_CurrentTarget() != null) && (SetAutoAttackLast < DateTime.Now)) && !CurrentTargetAttackable(50.0, false, false))
                {
                    Lua.DoString("RunMacroText('/stopattack');", "WoW.lua");
                    SetAutoAttackLast = DateTime.Now + TimeSpan.FromMilliseconds(2000.0);
                    return (RunStatus) RunStatus.Failure;
                }
                return (RunStatus) RunStatus.Failure;
            });
        }

        private static Composite SoulReaper()
        {
            return (Composite) new Decorator(ret => ((THSettings.Instance.SoulReaper && CurrentTargetAttackable(5.0, false, false)) && (Me.get_CurrentTarget().HealthPercent <= THSettings.Instance.SoulReaperHP)) && CanCastCheck("Soul Reaper", false), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Soul Reaper", Me.get_CurrentTarget(), "");
            }));
        }

        private static WoWSpell SpellFind(string spell)
        {
            SpellFindResults results;
            if (!SpellManager.FindSpell(spell, ref results))
            {
                return null;
            }
            return (results.Override ?? results.Original);
        }

        private static bool SpellOnCooldown(int spell)
        {
            SpellFindResults results;
            if (!SpellManager.FindSpell(spell, ref results))
            {
                return false;
            }
            if (results.Override == null)
            {
                return results.Original.Cooldown;
            }
            return results.Override.Cooldown;
        }

        private static bool SpellOnCooldown(string spell)
        {
            SpellFindResults results;
            if (!SpellManager.FindSpell(spell, ref results))
            {
                return false;
            }
            if (results.Override == null)
            {
                return results.Original.Cooldown;
            }
            return results.Override.Cooldown;
        }

        private static void SpellsCooldownCacheAdd(string spellName, DateTime spellCooldownBack)
        {
            if ((spellName == "Ice Trap") || (spellName == "Freezing Trap"))
            {
                SpellsCooldownCache.Add("Ice Trap", spellCooldownBack);
                SpellsCooldownCache.Add("Freezing Trap", spellCooldownBack);
            }
            else
            {
                SpellsCooldownCache.Add(spellName, spellCooldownBack);
            }
        }

        private static void SpellsCooldownCacheClear()
        {
            if (MeHasAura("Arena Preparation"))
            {
                SpellsCooldownCache.Clear();
            }
            else
            {
                foreach (string str in (from unit in SpellsCooldownCache
                    where unit.Value < DateTime.Now
                    select unit.Key).ToList<string>())
                {
                    try
                    {
                        SpellsCooldownCache.Remove(str);
                        continue;
                    }
                    catch (Exception)
                    {
                        Styx.Common.Logging.Write("Fail to SpellsCooldownCache.Remove({0})", new object[] { str });
                        throw;
                    }
                }
            }
        }

        private static Composite StrangulateLow()
        {
            return (Composite) new Decorator(ret => ((THSettings.Instance.StrangulateLow && (Me.get_CurrentMap().IsArena || Me.get_CurrentMap().IsBattleground)) && (Me.Combat && CanCastCheck("Strangulate", true))) && GetUnitStrangulateLow(), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                CastSpell("Strangulate", UnitStrangulateLow, "StrangulateLow");
                return (RunStatus) RunStatus.Failure;
            }));
        }

        private static void StrangulateVoid()
        {
            if (((THSettings.Instance.StrangulateInterrupt && ((LastInterrupt + TimeSpan.FromMilliseconds(1000.0)) < DateTime.Now)) && (Me.Combat && CanCastCheck("Strangulate", true))) && GetUnitStrangulateInterrupt())
            {
                if (Me.IsCasting)
                {
                    SpellManager.StopCasting();
                }
                FacingDelay = DateTime.Now;
                if ((THSettings.Instance.AutoFace && ((FacingDelay + TimeSpan.FromMilliseconds(100.0)) > DateTime.Now)) && !Me.IsFacing((WoWObject) UnitInterrupt))
                {
                    Me.SetFacing(UnitInterrupt);
                }
                if ((UnitInterrupt.IsCasting && (UnitInterrupt.CurrentCastTimeLeft.TotalMilliseconds > (MyLatency + 50.0))) || UnitInterrupt.IsChanneling)
                {
                    CastSpell("Strangulate", UnitInterrupt, "StrangulateVoid");
                    LastInterrupt = DateTime.Now;
                }
            }
        }

        private static void SVNCheck()
        {
            try
            {
                Styx.Common.Logging.Write("Newest SVN Revision: " + GetSVNRevision());
            }
            catch (Exception)
            {
                Styx.Common.Logging.Write("Can not get GetSVNRevision");
                return;
            }
            try
            {
                Styx.Common.Logging.Write("You are using Revision: " + GetLocalRevision());
            }
            catch (Exception)
            {
                Styx.Common.Logging.Write("Can not get GetLocalRevision");
                return;
            }
            if (((GetLocalRevision() != 0) && (GetSVNRevision() != 0)) && (GetSVNRevision() != GetLocalRevision()))
            {
                Styx.Common.Logging.Write("----------------------------------");
                Styx.Common.Logging.Write("A newer version with Improved Logic");
                Styx.Common.Logging.Write("And Bug Fix just uploaded to SVN server!");
                Styx.Common.Logging.Write("----------------------------------");
                Styx.Common.Logging.Write("Please update to the lastest Revision " + GetSVNRevision());
                Styx.Common.Logging.Write("----------------------------------");
                Styx.Common.Logging.Write("To Update please Close Honorbuddy");
                Styx.Common.Logging.Write("Then open folder");
                Styx.Common.Logging.Write(Path.Combine(Utilities.AssemblyDirectory, "Routines"));
                Styx.Common.Logging.Write("----------------------------------");
                Styx.Common.Logging.Write("Right Click Folder " + CombatRoutineFolder);
                Styx.Common.Logging.Write(" > SVN Update working copy. (If you see that option)");
                Styx.Common.Logging.Write("----------------------------------");
                Styx.Common.Logging.Write("Right Click Folder " + CombatRoutineFolder);
                Styx.Common.Logging.Write(" > SVN Update");
                Styx.Common.Logging.Write("----------------------------------");
            }
        }

        private static byte TalentSort(WoWUnit target)
        {
            if ((target != null) && target.IsValid)
            {
                switch (target.get_Class())
                {
                    case WoWClass.Warrior:
                        return 1;

                    case WoWClass.Paladin:
                        if (target.MaxMana <= (target.MaxHealth / 2))
                        {
                            return 1;
                        }
                        return 4;

                    case WoWClass.Hunter:
                        return 2;

                    case WoWClass.Rogue:
                        return 1;

                    case WoWClass.Priest:
                        if (!UnitHasAura(0x1c0c4, target))
                        {
                            return 4;
                        }
                        return 3;

                    case WoWClass.DeathKnight:
                        return 1;

                    case WoWClass.Shaman:
                        if (target.MaxMana >= (target.MaxHealth / 2))
                        {
                            if (UnitHasAura(0x3f55, target))
                            {
                                return 4;
                            }
                            return 3;
                        }
                        return 1;

                    case WoWClass.Mage:
                        return 3;

                    case WoWClass.Warlock:
                        return 3;

                    case WoWClass.Monk:
                        if (!UnitHasAura(0x1c17e, target))
                        {
                            return 1;
                        }
                        return 4;

                    case WoWClass.Druid:
                        if (target.MaxMana >= (target.MaxHealth / 2))
                        {
                            if (UnitHasAura(0x1a0ef, target))
                            {
                                return 4;
                            }
                            return 3;
                        }
                        return 1;
                }
            }
            return 0;
        }

        private static string TalentSortRole(WoWUnit target)
        {
            switch (TalentSort(target))
            {
                case 1:
                    return "Melee";

                case 2:
                    return "Range DPS";

                case 3:
                    return "Range DPS";

                case 4:
                    return "Healer";
            }
            return "Unknow";
        }

        private static byte TalentSortSimple(WoWUnit target)
        {
            byte num = TalentSort(target);
            if (num == 4)
            {
                return 4;
            }
            if ((num < 4) && (num > 0))
            {
                return 1;
            }
            return 0;
        }

        private static bool TalentValue(bool blood, bool frost, bool unholy)
        {
            if (GetCurrentSpec() == "Blood")
            {
                return blood;
            }
            if (!(GetCurrentSpec() == "Unholy"))
            {
                return frost;
            }
            return unholy;
        }

        private static int TalentValue(int blood, int frost, int unholy)
        {
            if (GetCurrentSpec() == "Blood")
            {
                return blood;
            }
            if (!(GetCurrentSpec() == "Unholy"))
            {
                return frost;
            }
            return unholy;
        }

        private static Composite TargetMyPetTarget()
        {
            return (Composite) new Decorator(ret => (((!CurrentTargetAttackable(40.0, false, false) && Me.Combat) && (IsUsingAFKBot && !Me.get_CurrentMap().IsArena)) && !Me.get_CurrentMap().IsBattleground) && GetUnitAttackingMyPet(), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                Styx.Common.Logging.Write((Styx.Common.LogLevel) Styx.Common.LogLevel.Diagnostic, "TargetMyPetTarget");
                UnitAttackingMyPet.Target();
                return (RunStatus) RunStatus.Failure;
            }));
        }

        private static Composite UnholyBlight()
        {
            return (Composite) new Decorator(delegate (object ret) {
                if ((!THSettings.Instance.UnholyBlight || !CurrentTargetAttackable(10.0, false, false)) || ((MyAuraTimeLeft("Frost Fever)", Me.get_CurrentTarget()) >= 2000.0) && (MyAuraTimeLeft("Blood Plague)", Me.get_CurrentTarget()) >= 2000.0)))
                {
                    return false;
                }
                return CanCastCheck("Unholy Blight", false);
            }, (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                SafelyFacingTarget(Me.get_CurrentTarget());
                CastSpell("Unholy Blight", (WoWUnit) Me, "");
            }));
        }

        private static Composite UnholyPresenceSwap()
        {
            return (Composite) new Decorator(delegate (object ret) {
                if ((((!THSettings.Instance.AutoPrecence || ((PresenceSwapLast + TimeSpan.FromMilliseconds((double) THSettings.Instance.PresenceSwapTimeout)) >= DateTime.Now)) || (MeHasAura("Unholy Presence") || MeHasAura("Alliance Flag"))) || ((MeHasAura("Horde Flag") || MeHasAura("Netherstorm Flag")) || MeHasAura("Orb of Power"))) || ((Me.HealthPercent <= THSettings.Instance.BloodPresenceHP) && !Burst))
                {
                    return false;
                }
                return CanCastCheck("Unholy Presence", false);
            }, (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                PresenceSwapLast = DateTime.Now;
                CastSpell("Unholy Presence", (WoWUnit) Me, "UnholyPresence");
            }));
        }

        private static Composite UnholyRotation()
        {
            Composite[] compositeArray = new Composite[] { 
                AutoTarget(), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                    if (((TreeRoot.get_Current().Name != "DungeonBuddy") && (Me.get_CurrentMap().IsDungeon || Me.get_CurrentMap().IsRaid)) && (((!Me.Combat && (Me.get_CurrentTarget() != null)) && (IsEnemy(Me.get_CurrentTarget()) && !Me.get_CurrentTarget().IsTargetingMyPartyMember)) && (!Me.get_CurrentTarget().IsTargetingMyRaidMember && !Me.get_CurrentTarget().IsTargetingMeOrPet)))
                    {
                        return (RunStatus) RunStatus.Success;
                    }
                    if (((THSettings.Instance.AutoAoE && (THSettings.Instance.UnittoStartAoE > 0)) && (!Me.get_CurrentMap().IsArena && !Me.get_CurrentMap().IsBattleground)) && (CountEnemyNear((WoWUnit) Me, 15f) >= THSettings.Instance.UnittoStartAoE))
                    {
                        _aoEModeOn = true;
                    }
                    else
                    {
                        _aoEModeOn = false;
                    }
                    return (RunStatus) RunStatus.Failure;
                }), MovementMoveStop(ret => Me.get_CurrentTarget(), 3.0), MovementMoveToMelee(ret => Me.get_CurrentTarget()), IceboundFortitudeStun(), DesecratedGround(), TargetMyPetTarget(), PetAttack(), PetLeap(), UseHealthstone(), UseBattleStandard(), Huddle(), PetFollow(), IceboundFortitude(), LichborneHeal(), AntiMagicShell(), 
                AntiMagicShellLichborne(), AntiMagicShellEnemy(), AntiMagicShellDebuff(), AntiMagicShellCaster(), AntiMagicZone(), AntiMagicZoneDebuff(), AntiMagicZoneCaster(), DeathGrip(), EmpowerRuneWeapon(), BloodFury(), BloodTap(), DarkSimulacrum(), DarkSimulacrumUse(), DeathsAdvance(), StrangulateLow(), DeathGrip(), 
                DeathGripAsphyxiateHelpFriend(), DeathGripRemorselessWinter(), UnholyPresenceSwap(), BloodPresenceSwap(), HornofWinterBuff(), RaiseAlly(), RaiseDeadUnholy(), (Composite) new Decorator(ret => !_aoEModeOn, (Composite) new PrioritySelector(new Composite[] { 
                    AttackASAP(), DarkSuccor(), SoulReaper(), DarkTransformation(), GargoyleFrenzy(), GorefiendsGraspAoE(), GorefiendsGraspKiter(), GorefiendsGraspMelee(), IcyTouchDispel(), RemorselessWinter(), RemorselessWinterEnemyLowHP(), RemorselessWinterEnemyNumber(), RemorselessWinterBurst(), DeathCoilHeal(), ChainsofIce(), ChainsofIceMelee(), 
                    DeathandDecaySnare(), DeathPact(), DeathSiphon(), Conversion(), PlagueLeech(), Outbreak(), UnholyBlight(), PlagueStrikeDebuff(), IcyTouchDebuffUnholy(), BloodBoilRoilingBlood(), Pestilence(), DeathCoilShadowInfusion(), DeathCoilHealPet(), NecroticStrikeStackMax(), ScourgeStrike90(), FesteringStrike90(), 
                    DeathCoilProc(), DeathCoilCapRunicPower(), NecroticStrikeStack(), ScourgeStrike(), FesteringStrike(), BloodBoilRoilingBloodConversion(), BloodStrikeConversion(), IcyTouchConversion(), IcyTouchDispelLowPriority(), ControlUndead(), ControlUndeadUpdate(), DeathStrike(), BloodStrike(), HornofWinter(), DeathCoilUnholy(), Presence(), 
                    PathofFrost()
                 })), (Composite) new Decorator(ret => _aoEModeOn, (Composite) new PrioritySelector(new Composite[] { 
                    DarkSuccor(), SoulReaper(), DarkTransformation(), GargoyleFrenzy(), PlagueLeech(), Outbreak(), UnholyBlight(), BloodBoilRoilingBlood(), Pestilence(), IcyTouchDebuffUnholy(), PlagueStrikeDebuff(), FesteringStrike(), BloodBoilUnholyAoE(), DeathandDecayAoE(), DeathCoilHealPet(), DeathCoilProc(), 
                    DeathCoilCapRunicPower(), DeathCoilShadowInfusion(), IcyTouchConversion(), BloodStrikeConversion(), DeathPact(), DeathSiphon(), Conversion(), HornofWinter(), Presence(), PathofFrost()
                 })), RestRotation()
             };
            return (Composite) new PrioritySelector(compositeArray);
        }

        private static bool UnitHasAura(int auraID, WoWUnit target)
        {
            return target.GetAllAuras().Any<WoWAura>(aura => (aura.SpellId == auraID));
        }

        private static bool UnitHasAura(string auraName, WoWUnit target)
        {
            return target.GetAllAuras().Any<WoWAura>(aura => (aura.Name == auraName));
        }

        private static void UpdateEventHandler()
        {
            if (((IsUsingAFKBot && !Me.get_CurrentMap().IsArena) && (!Me.get_CurrentMap().IsBattleground && !Me.get_CurrentMap().IsDungeon)) && (!Me.get_CurrentMap().IsRaid && !EventHandlers.CombatLogAttached))
            {
                EventHandlers.AttachCombatLogEvent();
            }
            if (((!IsUsingAFKBot || Me.get_CurrentMap().IsArena) || ((Me.get_CurrentMap().IsBattleground || Me.get_CurrentMap().IsDungeon) || Me.get_CurrentMap().IsRaid)) && EventHandlers.CombatLogAttached)
            {
                EventHandlers.DetachCombatLogEvent();
            }
        }

        private static void UpdateMyGlyph()
        {
            HasGlyph = "";
            HasGlyphName = "";
            int returnVal = Lua.GetReturnVal<int>("return GetNumGlyphSockets()", 0);
            if (returnVal != 0)
            {
                for (int i = 1; i <= returnVal; i++)
                {
                    int num3 = Lua.GetReturnVal<int>(string.Format("local enabled, glyphType, glyphTooltipIndex, glyphSpellID, icon = GetGlyphSocketInfo({0});if (enabled) then return glyphSpellID else return 0 end", i), 0);
                    try
                    {
                        if (num3 > 0)
                        {
                            HasGlyphName = string.Concat(new object[] { HasGlyphName, "[", WoWSpell.FromId(num3), " - ", num3, "] " });
                            HasGlyph = string.Concat(new object[] { HasGlyph, "[", num3, "] " });
                        }
                        else
                        {
                            Styx.Common.Logging.Write("Glyphdetection - No Glyph in slot " + i);
                        }
                    }
                    catch (Exception exception)
                    {
                        Styx.Common.Logging.Write("We couldn't detect your Glyphs");
                        Styx.Common.Logging.Write("Report this message to us: " + exception);
                    }
                }
            }
            Styx.Common.Logging.Write("----------------------------------");
            Styx.Common.Logging.Write("Glyph:");
            Styx.Common.Logging.Write(HasGlyphName);
            Styx.Common.Logging.Write("----------------------------------");
            if (HasGlyph.Contains("58657"))
            {
                GlyphprivateofPestilenceBonus = 5;
            }
        }

        private static void UpdateMyGlyphEvent(object sender, LuaEventArgs args)
        {
            UpdateMyGlyph();
        }

        private static void UpdateMyLatency()
        {
            MyLatency = StyxWoW.get_WoWClient().Latency;
            if (MyLatency > 400.0)
            {
                MyLatency = 400.0;
            }
        }

        private static void UpdateMyNoGCDSpell()
        {
            if (SpellManager.HasSpell("Anti-Magic Shell"))
            {
                NoGCDSpells.Add("Anti-Magic Shell");
            }
            if (SpellManager.HasSpell("Blood Tap"))
            {
                NoGCDSpells.Add("Blood Tap");
            }
            if (SpellManager.HasSpell("Dancing Rune Weapon"))
            {
                NoGCDSpells.Add("Dancing Rune Weapon");
            }
            if (SpellManager.HasSpell("Dark Command"))
            {
                NoGCDSpells.Add("Dark Command");
            }
            if (SpellManager.HasSpell("Dark Simulacrum"))
            {
                NoGCDSpells.Add("Dark Simulacrum");
            }
            if (SpellManager.HasSpell("Death Pact"))
            {
                NoGCDSpells.Add("Death Pact");
            }
            if (SpellManager.HasSpell("Empower Rune Weapon"))
            {
                NoGCDSpells.Add("Empower Rune Weapon");
            }
            if (SpellManager.HasSpell("Icebound Fortitude"))
            {
                NoGCDSpells.Add("Icebound Fortitude");
            }
            if (SpellManager.HasSpell("Lichborne"))
            {
                NoGCDSpells.Add("Lichborne");
            }
            if (SpellManager.HasSpell("Mind Freeze"))
            {
                NoGCDSpells.Add("Mind Freeze");
            }
            if (SpellManager.HasSpell("Rune Tap"))
            {
                NoGCDSpells.Add("Rune Tap");
            }
            if (SpellManager.HasSpell("Vampiric Blood"))
            {
                NoGCDSpells.Add("Vampiric Blood");
            }
            Styx.Common.Logging.Write("----------------------------------");
            Styx.Common.Logging.Write("Spells that don't use Global Cooldown:");
            foreach (string str in NoGCDSpells)
            {
                Styx.Common.Logging.Write(" -" + str);
            }
            Styx.Common.Logging.Write("----------------------------------");
        }

        private static void UpdateMyTalent()
        {
            _hasTalent = "";
            for (int i = 1; i <= 0x12; i++)
            {
                _hasTalent = _hasTalent + Lua.GetReturnVal<string>(string.Format("local t= select(5,GetTalentInfo({0})) if t == true then return '['..select(1,GetTalentInfo({0}))..'] ' end return nil", i), 0);
            }
            Styx.Common.Logging.Write("----------------------------------");
            Styx.Common.Logging.Write("Talent:");
            Styx.Common.Logging.Write(_hasTalent);
            Styx.Common.Logging.Write("----------------------------------");
            _hasTalent = "";
        }

        private static void UpdateMyTalentEvent(object sender, LuaEventArgs args)
        {
            UpdateMyTalent();
        }

        private static void UpdateStatus()
        {
            if (THSettings.Instance.UpdateStatus && Me.IsValid)
            {
                BurstLast = DateTime.Now;
                Styx.Common.Logging.Write("----------------------------------");
                Styx.Common.Logging.Write("Building Rotation base on current Talents and Glyphs......");
                Styx.Common.Logging.Write("----------------------------------");
                Styx.Common.Logging.Write("");
                UpdateEventHandler();
                UpdateMyTalent();
                UpdateMyGlyph();
                PetSpellsUpdate();
                if (Me.get_Specialization() == ((WoWSpec) ((int) WoWSpec.DeathKnightBlood)))
                {
                    UseSpecialization = 1;
                }
                else if (Me.get_Specialization() == ((WoWSpec) ((int) WoWSpec.DeathKnightFrost)))
                {
                    UseSpecialization = 2;
                }
                else
                {
                    UseSpecialization = 3;
                }
                Styx.Common.Logging.Write("----------------------------------");
                Styx.Common.Logging.Write("Hold 1 second Control + " + IndexToKeys(THSettings.Instance.PauseKey) + " To Toggle Pause Mode.");
                Styx.Common.Logging.Write("----------------------------------");
                Styx.Common.Logging.Write("");
                if ((((TreeRoot.get_Current().Name == "Questing") || (TreeRoot.get_Current().Name == "[BETA] Grindbuddy")) || ((TreeRoot.get_Current().Name == "ArcheologyBuddy") || (TreeRoot.get_Current().Name == "Auto Angler"))) || (((TreeRoot.get_Current().Name == "Gatherbuddy2") || (TreeRoot.get_Current().Name == "Grind Bot")) || (((TreeRoot.get_Current().Name == "BGBuddy") || (TreeRoot.get_Current().Name == "DungeonBuddy")) || (TreeRoot.get_Current().Name == "Mixed Mode"))))
                {
                    IsUsingAFKBot = true;
                }
                else
                {
                    IsUsingAFKBot = false;
                }
                MeMaxHealth = Me.MaxHealth;
                if (THSettings.Instance.BurstKey > 7)
                {
                    Styx.Common.Logging.Write("----------------------------------");
                    Styx.Common.Logging.Write("Hold 1 second + " + IndexToKeys(THSettings.Instance.BurstKey - 7) + " To Toggle Burst Mode");
                    Styx.Common.Logging.Write("----------------------------------");
                    Styx.Common.Logging.Write("");
                }
                Styx.Common.Logging.Write("----------------------------------");
                Styx.Common.Logging.Write("Building Rotation Completed");
                Styx.Common.Logging.Write("----------------------------------");
                Styx.Common.Logging.Write("");
                THSettings.Instance.UpdateStatus = false;
                SVNCheck();
            }
        }

        private static void UpdateStatusEvent(object sender, LuaEventArgs args)
        {
            THSettings.Instance.UpdateStatus = true;
        }

        private static Composite UseBattleStandard()
        {
            return (Composite) new Decorator(ret => (((THSettings.Instance.HealthStone && Me.Combat) && ((Me.HealthPercent < THSettings.Instance.HealthStoneHP) && (Me.get_CurrentTarget() != null))) && (Me.get_CurrentTarget().CurrentHealth > Me.HealthPercent)) && Me.get_CurrentMap().IsBattleground, (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                if (Me.IsAlliance)
                {
                    WoWItem item = Me.get_BagItems().FirstOrDefault<WoWItem>(o => o.Entry == 0x48ae);
                    if ((!MeHasAura("Alliance Battle Standard") && (item != null)) && (item.CooldownTimeLeft.TotalMilliseconds <= MyLatency))
                    {
                        item.Use();
                        Styx.Common.Logging.Write("Use Battle Standard at " + Me.HealthPercent + "%");
                    }
                }
                if (Me.IsHorde)
                {
                    WoWItem item2 = Me.get_BagItems().FirstOrDefault<WoWItem>(o => o.Entry == 0x48af);
                    if ((!MeHasAura("Horde Battle Standard") && (item2 != null)) && (item2.CooldownTimeLeft.TotalMilliseconds <= MyLatency))
                    {
                        item2.Use();
                        Styx.Common.Logging.Write("Use Battle Standard at " + Me.HealthPercent + "%");
                    }
                }
                return (RunStatus) RunStatus.Failure;
            }));
        }

        private static Composite UseHealthstone()
        {
            return (Composite) new Decorator(ret => ((THSettings.Instance.HealthStone && Me.Combat) && ((Me.HealthPercent < THSettings.Instance.HealthStoneHP) && (Me.get_CurrentTarget() != null))) && (Me.get_CurrentTarget().CurrentHealth > Me.HealthPercent), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                WoWItem item = Me.get_BagItems().FirstOrDefault<WoWItem>(o => o.Entry == 0x1588);
                if ((item != null) && (item.CooldownTimeLeft.TotalMilliseconds <= MyLatency))
                {
                    item.Use();
                    Styx.Common.Logging.Write("Use Healthstone at " + Me.HealthPercent + "%");
                }
                return (RunStatus) RunStatus.Failure;
            }));
        }

        private static Composite UseProfession()
        {
            Composite[] compositeArray = new Composite[] { (Composite) new Decorator(ret => ((((THSettings.Instance.ProfBuff == 1) && Me.Combat) && (CurrentTargetAttackable(10.0, false, false) && FacingOverride(Me.get_CurrentTarget()))) && (Me.get_Inventory().get_Equipped().get_Hands() != null)) && CanUseCheck(Me.get_Inventory().get_Equipped().get_Hands()), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                Styx.Common.Logging.Write("Use: Gloves Buff Activated on Cooldown");
                StyxWoW.get_Me().get_Inventory().get_Equipped().get_Hands().Use();
                return (RunStatus) RunStatus.Failure;
            })), (Composite) new Decorator(ret => ((((THSettings.Instance.ProfBuff == 2) && Me.Combat) && (CurrentTargetAttackable(10.0, false, false) && Me.get_CurrentTarget().IsBoss)) && (FacingOverride(Me.get_CurrentTarget()) && (Me.get_Inventory().get_Equipped().get_Hands() != null))) && CanUseCheck(Me.get_Inventory().get_Equipped().get_Hands()), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                Styx.Common.Logging.Write("Use: Gloves Buff Activated on Cooldown (Boss Only)");
                StyxWoW.get_Me().get_Inventory().get_Equipped().get_Hands().Use();
                return (RunStatus) RunStatus.Failure;
            })), (Composite) new Decorator(ret => ((((THSettings.Instance.ProfBuff == 3) && Burst) && (Me.Combat && CurrentTargetAttackable(15.0, false, false))) && (Me.get_Inventory().get_Equipped().get_Hands() != null)) && CanUseCheck(Me.get_Inventory().get_Equipped().get_Hands()), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                Styx.Common.Logging.Write("Use: Gloves Buff Activated on Burst Mode");
                StyxWoW.get_Me().get_Inventory().get_Equipped().get_Hands().Use();
                return (RunStatus) RunStatus.Failure;
            })), (Composite) new Decorator(ret => (((THSettings.Instance.ProfBuff == 4) && Me.Combat) && (CurrentTargetAttackable(10.0, false, false) && DebuffCCDuration((WoWUnit) Me, 3000.0, false))) && CanUseCheck(Me.get_Inventory().get_Equipped().get_Hands()), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                Styx.Common.Logging.Write("Use: Gloves Buff Activated on Lose Control");
                StyxWoW.get_Me().get_Inventory().get_Equipped().get_Hands().Use();
                return (RunStatus) RunStatus.Failure;
            })), (Composite) new Decorator(ret => ((((THSettings.Instance.ProfBuff == 5) && Me.Combat) && ((Me.get_Inventory().get_Equipped().get_Hands() != null) && CurrentTargetAttackable(10.0, false, false))) && (Me.HealthPercent < THSettings.Instance.ProfBuffHP)) && CanUseCheck(Me.get_Inventory().get_Equipped().get_Hands()), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                Styx.Common.Logging.Write("Use: GLoves Buff Activated on Low HP");
                StyxWoW.get_Me().get_Inventory().get_Equipped().get_Hands().Use();
                return (RunStatus) RunStatus.Failure;
            })), (Composite) new Decorator(ret => ((((THSettings.Instance.ProfBuff == 6) && Me.Combat) && ((Me.get_Inventory().get_Equipped().get_Hands() != null) && CurrentTargetAttackable(10.0, false, false))) && (!Me.get_CurrentTarget().IsPet && (Me.get_CurrentTarget().HealthPercent < THSettings.Instance.ProfBuffHP))) && CanUseCheck(Me.get_Inventory().get_Equipped().get_Hands()), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                Styx.Common.Logging.Write("Use: Gloves Buff Activated on Enemy Unit Low HP");
                StyxWoW.get_Me().get_Inventory().get_Equipped().get_Hands().Use();
                return (RunStatus) RunStatus.Failure;
            })), (Composite) new Decorator(delegate (object ret) {
                if ((((THSettings.Instance.ProfBuff != 1) || !Me.Combat) || !CurrentTargetAttackable(10.0, false, false)) || (!MeHasAura(0xc847) && !MeHasAura("Unholy Frenzy")))
                {
                    return false;
                }
                return CanCastCheck("Lifeblood", true);
            }, (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                Styx.Common.Logging.Write("Use: Lifeblood Activated on Cooldown");
                CastSpell("Lifeblood", (WoWUnit) Me, "");
                return (RunStatus) RunStatus.Failure;
            })), (Composite) new Decorator(ret => (((THSettings.Instance.ProfBuff == 2) && Me.Combat) && (CurrentTargetAttackable(10.0, false, false) && MeHasAura(0xc847))) && CanCastCheck("Lifeblood", true), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                Styx.Common.Logging.Write("Use: Lifeblood Activated on Cooldown (Boss Only)");
                CastSpell("Lifeblood", (WoWUnit) Me, "");
                return (RunStatus) RunStatus.Failure;
            })), (Composite) new Decorator(ret => (((THSettings.Instance.ProfBuff == 3) && Burst) && (Me.Combat && CurrentTargetAttackable(15.0, false, false))) && CanCastCheck("Lifeblood", true), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                Styx.Common.Logging.Write("Use: Lifeblood Activated on Burst Mode");
                CastSpell("Lifeblood", (WoWUnit) Me, "");
                return (RunStatus) RunStatus.Failure;
            })), (Composite) new Decorator(ret => (((THSettings.Instance.ProfBuff == 4) && Me.Combat) && DebuffCCDuration((WoWUnit) Me, 3000.0, false)) && CanCastCheck("Lifeblood", true), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                Styx.Common.Logging.Write("Use: Lifeblood Activated on Lose Control");
                CastSpell("Lifeblood", (WoWUnit) Me, "");
                return (RunStatus) RunStatus.Failure;
            })), (Composite) new Decorator(ret => (((THSettings.Instance.ProfBuff == 5) && Me.Combat) && (Me.HealthPercent < THSettings.Instance.ProfBuffHP)) && CanCastCheck("Lifeblood", true), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                Styx.Common.Logging.Write("Use: Lifeblood Activated on Low HP");
                CastSpell("Lifeblood", (WoWUnit) Me, "");
                return (RunStatus) RunStatus.Failure;
            })), (Composite) new Decorator(ret => ((((THSettings.Instance.ProfBuff == 6) && Me.Combat) && ((Me.get_CurrentTarget() != null) && Me.get_CurrentTarget().IsValid)) && ((IsEnemy(Me.get_CurrentTarget()) && !Me.get_CurrentTarget().IsPet) && ((GetDistance(Me.get_CurrentTarget()) <= 5f) && (Me.get_CurrentTarget().HealthPercent < THSettings.Instance.ProfBuffHP)))) && CanCastCheck("Lifeblood", true), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                Styx.Common.Logging.Write("Use: Lifeblood Activated on Enemy Unit Low HP");
                CastSpell("Lifeblood", (WoWUnit) Me, "Use: Lifeblood Activated on Enemy Unit Low HP");
                return (RunStatus) RunStatus.Failure;
            })) };
            return (Composite) new PrioritySelector(compositeArray);
        }

        private static Composite UseRacial()
        {
            Composite[] compositeArray = new Composite[] { (Composite) new Decorator(ret => (((Me.Combat && THSettings.Instance.AutoRacial) && (((BreakCCLast + TimeSpan.FromMilliseconds(2000.0)) < DateTime.Now) && DebuffCCDuration((WoWUnit) Me, 3000.0, false))) && !MeHasAura("Sap")) && CanCastCheck("Every Man for Himself", true), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                if ((THSettings.Instance.AutoTarget && (Me.get_CurrentTarget() == null)) && ((MyLastTarget != null) && MyLastTarget.IsValid))
                {
                    MyLastTarget.Target();
                }
                if (DebuffCCBreakonDamage((WoWUnit) Me) && DebuffDot((WoWUnit) Me))
                {
                    Styx.Common.Logging.Write("Waiting for Dot / Hand of Sacrifice break it!");
                }
                else
                {
                    BreakCCLast = DateTime.Now;
                    Styx.Common.Logging.Write("Use: Every Man for Himself");
                    CastSpell("Every Man for Himself", (WoWUnit) Me, "");
                }
                return (RunStatus) RunStatus.Failure;
            })), (Composite) new Decorator(ret => ((Me.Combat && THSettings.Instance.AutoRacial) && (Me.HealthPercent < THSettings.Instance.UrgentHeal)) && CanCastCheck("Stoneform", true), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                Styx.Common.Logging.Write("Stoneform");
                CastSpell("Stoneform", (WoWUnit) Me, "");
                return (RunStatus) RunStatus.Failure;
            })), (Composite) new Decorator(ret => ((Me.Combat && THSettings.Instance.AutoRacial) && (Me.HealthPercent < THSettings.Instance.UrgentHeal)) && CanCastCheck("Gift of the Naaru", true), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                Styx.Common.Logging.Write("Gift of the Naaru");
                CastSpell("Gift of the Naaru", (WoWUnit) Me, "");
            })) };
            return (Composite) new PrioritySelector(compositeArray);
        }

        private static Composite UseTrinket()
        {
            Composite[] compositeArray = new Composite[] { (Composite) new Decorator(ret => ((((THSettings.Instance.Trinket1 == 1) && Me.Combat) && (CurrentTargetAttackable(10.0, false, false) && FacingOverride(Me.get_CurrentTarget()))) && (Me.get_Inventory().get_Equipped().get_Trinket1() != null)) && CanUseCheck(Me.get_Inventory().get_Equipped().get_Trinket1()), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                Styx.Common.Logging.Write("Activate " + StyxWoW.get_Me().get_Inventory().get_Equipped().get_Trinket1().Name + " on Cooldown");
                StyxWoW.get_Me().get_Inventory().get_Equipped().get_Trinket1().Use();
                return (RunStatus) RunStatus.Failure;
            })), (Composite) new Decorator(ret => ((((THSettings.Instance.Trinket1 == 2) && Me.Combat) && (CurrentTargetAttackable(10.0, false, false) && Me.get_CurrentTarget().IsBoss)) && (FacingOverride(Me.get_CurrentTarget()) && (Me.get_Inventory().get_Equipped().get_Trinket1() != null))) && CanUseCheck(Me.get_Inventory().get_Equipped().get_Trinket1()), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                Styx.Common.Logging.Write("Activate " + StyxWoW.get_Me().get_Inventory().get_Equipped().get_Trinket1().Name + " on Cooldown (Boss Only)");
                StyxWoW.get_Me().get_Inventory().get_Equipped().get_Trinket1().Use();
                return (RunStatus) RunStatus.Failure;
            })), (Composite) new Decorator(ret => ((((THSettings.Instance.Trinket1 == 3) && Burst) && (Me.Combat && CurrentTargetAttackable(15.0, false, false))) && (Me.get_Inventory().get_Equipped().get_Trinket1() != null)) && CanUseCheck(Me.get_Inventory().get_Equipped().get_Trinket1()), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                Styx.Common.Logging.Write("Activate " + StyxWoW.get_Me().get_Inventory().get_Equipped().get_Trinket1().Name + " on Burst Mode");
                StyxWoW.get_Me().get_Inventory().get_Equipped().get_Trinket1().Use();
                return (RunStatus) RunStatus.Failure;
            })), (Composite) new Decorator(ret => ((((THSettings.Instance.Trinket1 == 4) && ((BreakCCLast + TimeSpan.FromMilliseconds(2000.0)) < DateTime.Now)) && (Me.Combat && (Me.get_Inventory().get_Equipped().get_Trinket1() != null))) && (DebuffCCDuration((WoWUnit) Me, 3000.0, false) && !MeHasAura("Sap"))) && CanUseCheck(Me.get_Inventory().get_Equipped().get_Trinket1()), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                BreakCCLast = DateTime.Now;
                StyxWoW.get_Me().get_Inventory().get_Equipped().get_Trinket1().Use();
                Styx.Common.Logging.Write("Activate " + StyxWoW.get_Me().get_Inventory().get_Equipped().get_Trinket1().Name + " on Lose Control");
                return (RunStatus) RunStatus.Failure;
            })), (Composite) new Decorator(ret => (((THSettings.Instance.Trinket1 == 5) && Me.Combat) && ((Me.get_Inventory().get_Equipped().get_Trinket1() != null) && (Me.HealthPercent < THSettings.Instance.Trinket1HP))) && CanUseCheck(Me.get_Inventory().get_Equipped().get_Trinket1()), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                Styx.Common.Logging.Write("Activate " + StyxWoW.get_Me().get_Inventory().get_Equipped().get_Trinket1().Name + " on Low HP");
                StyxWoW.get_Me().get_Inventory().get_Equipped().get_Trinket1().Use();
                return (RunStatus) RunStatus.Failure;
            })), (Composite) new Decorator(ret => ((((THSettings.Instance.Trinket1 == 6) && Me.Combat) && ((Me.get_Inventory().get_Equipped().get_Trinket1() != null) && CurrentTargetAttackable(10.0, false, false))) && (Me.get_CurrentTarget().HealthPercent < THSettings.Instance.Trinket1HP)) && CanUseCheck(Me.get_Inventory().get_Equipped().get_Trinket1()), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                Styx.Common.Logging.Write("Activate " + StyxWoW.get_Me().get_Inventory().get_Equipped().get_Trinket1().Name + " on Enemy Unit Low HP");
                StyxWoW.get_Me().get_Inventory().get_Equipped().get_Trinket1().Use();
                return (RunStatus) RunStatus.Failure;
            })), (Composite) new Decorator(ret => ((((THSettings.Instance.Trinket2 == 1) && Me.Combat) && (CurrentTargetAttackable(10.0, false, false) && FacingOverride(Me.get_CurrentTarget()))) && (Me.get_Inventory().get_Equipped().get_Trinket2() != null)) && CanUseCheck(Me.get_Inventory().get_Equipped().get_Trinket2()), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                Styx.Common.Logging.Write("Activate " + StyxWoW.get_Me().get_Inventory().get_Equipped().get_Trinket2().Name + " on Cooldown");
                StyxWoW.get_Me().get_Inventory().get_Equipped().get_Trinket2().Use();
                return (RunStatus) RunStatus.Failure;
            })), (Composite) new Decorator(ret => ((((THSettings.Instance.Trinket2 == 2) && Me.Combat) && (CurrentTargetAttackable(10.0, false, false) && Me.get_CurrentTarget().IsBoss)) && (FacingOverride(Me.get_CurrentTarget()) && (Me.get_Inventory().get_Equipped().get_Trinket2() != null))) && CanUseCheck(Me.get_Inventory().get_Equipped().get_Trinket2()), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                Styx.Common.Logging.Write("Activate " + StyxWoW.get_Me().get_Inventory().get_Equipped().get_Trinket2().Name + " on Cooldown (Boss Only)");
                StyxWoW.get_Me().get_Inventory().get_Equipped().get_Trinket2().Use();
                return (RunStatus) RunStatus.Failure;
            })), (Composite) new Decorator(ret => ((((THSettings.Instance.Trinket2 == 3) && Burst) && (Me.Combat && CurrentTargetAttackable(15.0, false, false))) && (Me.get_Inventory().get_Equipped().get_Trinket2() != null)) && CanUseCheck(Me.get_Inventory().get_Equipped().get_Trinket2()), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                Styx.Common.Logging.Write("Activate " + StyxWoW.get_Me().get_Inventory().get_Equipped().get_Trinket2().Name + " on Burst Mode");
                StyxWoW.get_Me().get_Inventory().get_Equipped().get_Trinket2().Use();
                return (RunStatus) RunStatus.Failure;
            })), (Composite) new Decorator(ret => ((((THSettings.Instance.Trinket2 == 4) && ((BreakCCLast + TimeSpan.FromMilliseconds(2000.0)) < DateTime.Now)) && (Me.Combat && (Me.get_Inventory().get_Equipped().get_Trinket2() != null))) && (DebuffCCDuration((WoWUnit) Me, 3000.0, false) && !MeHasAura("Sap"))) && CanUseCheck(Me.get_Inventory().get_Equipped().get_Trinket2()), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                BreakCCLast = DateTime.Now;
                StyxWoW.get_Me().get_Inventory().get_Equipped().get_Trinket2().Use();
                Styx.Common.Logging.Write("Activate " + StyxWoW.get_Me().get_Inventory().get_Equipped().get_Trinket2().Name + " on Lose Control");
                return (RunStatus) RunStatus.Failure;
            })), (Composite) new Decorator(ret => (((THSettings.Instance.Trinket2 == 5) && Me.Combat) && ((Me.get_Inventory().get_Equipped().get_Trinket2() != null) && (Me.HealthPercent < THSettings.Instance.Trinket2HP))) && CanUseCheck(Me.get_Inventory().get_Equipped().get_Trinket2()), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                Styx.Common.Logging.Write("Activate " + StyxWoW.get_Me().get_Inventory().get_Equipped().get_Trinket2().Name + " on Low HP");
                StyxWoW.get_Me().get_Inventory().get_Equipped().get_Trinket2().Use();
                return (RunStatus) RunStatus.Failure;
            })), (Composite) new Decorator(ret => ((((THSettings.Instance.Trinket2 == 6) && Me.Combat) && ((Me.get_Inventory().get_Equipped().get_Trinket2() != null) && CurrentTargetAttackable(10.0, false, false))) && (Me.get_CurrentTarget().HealthPercent < THSettings.Instance.Trinket2HP)) && CanUseCheck(Me.get_Inventory().get_Equipped().get_Trinket2()), (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                Styx.Common.Logging.Write("Activate " + StyxWoW.get_Me().get_Inventory().get_Equipped().get_Trinket2().Name + " on Enemy Unit Low HP");
                StyxWoW.get_Me().get_Inventory().get_Equipped().get_Trinket2().Use();
                return (RunStatus) RunStatus.Failure;
            })) };
            return (Composite) new PrioritySelector(compositeArray);
        }

        private static Composite VampiricBlood()
        {
            return (Composite) new Decorator(ret => ((THSettings.Instance.VampiricBlood && Me.Combat) && (Me.HealthPercent <= THSettings.Instance.VampiricBloodHP)) && CanCastCheck("Vampiric Blood", true), (Composite) new Styx.TreeSharp.Action(delegate (object ret) {
                CastSpell("Vampiric Blood", (WoWUnit) Me, "");
                return (RunStatus) RunStatus.Failure;
            }));
        }

        private static Composite WriteDebug(string message)
        {
            return (Composite) new Styx.TreeSharp.Action(delegate (object param0) {
                if (message != "")
                {
                    object[] objArray = new object[4];
                    objArray[0] = "(";
                    TimeSpan span = (TimeSpan) (DateTime.Now - LastWriteDebug);
                    objArray[1] = Math.Round(span.TotalMilliseconds, 0);
                    objArray[2] = ") ";
                    objArray[3] = message;
                    Styx.Common.Logging.Write(string.Concat(objArray));
                    LastWriteDebug = DateTime.Now;
                }
                return (RunStatus) RunStatus.Failure;
            });
        }

        public override WoWClass Class
        {
            get
            {
                return (WoWClass) WoWClass.DeathKnight;
            }
        }

        public override Composite CombatBehavior
        {
            get
            {
                return this._combatBehavior;
            }
        }

        public override Composite DeathBehavior
        {
            get
            {
                return this._deathBehavior;
            }
        }

        private static IEnumerable<WoWPartyMember> GroupMembers
        {
            get
            {
                if (Me.get_GroupInfo().IsInRaid)
                {
                    return Me.get_GroupInfo().get_RaidMembers();
                }
                return Me.get_GroupInfo().get_PartyMembers();
            }
        }

        private static LocalPlayer Me
        {
            get
            {
                return StyxWoW.get_Me();
            }
        }

        private static double MobsNearby
        {
            [CompilerGenerated]
            get
            {
                return <MobsNearby>k__BackingField;
            }
            [CompilerGenerated]
            set
            {
                <MobsNearby>k__BackingField = value;
            }
        }

        public override string Name
        {
            get
            {
                return "TuanHA Death Knight [Special Edition]";
            }
        }

        public override Composite PreCombatBuffBehavior
        {
            get
            {
                return this._preCombatBuffBehavior;
            }
        }

        public override Composite RestBehavior
        {
            get
            {
                return this._restBehavior;
            }
        }

        private static string SelfRezSpell
        {
            [CompilerGenerated]
            get
            {
                return <SelfRezSpell>k__BackingField;
            }
            [CompilerGenerated]
            set
            {
                <SelfRezSpell>k__BackingField = value;
            }
        }

        public override bool WantButton
        {
            get
            {
                return true;
            }
        }

        public delegate float DynamicRangeRetriever(object context);

        public delegate WoWPoint LocationRetriever(object context);

        public delegate WoWPoint LocationRetriverDelegate(object context);

        public delegate bool SimpleBooleanDelegate(object context);

        public delegate WoWUnit UnitSelectionDelegate(object context);
    }
}

